Changeset ecf823a in mainline
- Timestamp:
- 2011-12-31T10:01:19Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 96cd5b4
- Parents:
- 3819ce5 (diff), 852052d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.common
r3819ce5 recf823a 128 128 nic/lo \ 129 129 nic/ne2k \ 130 nic/e1k 130 nic/e1k \ 131 nic/rtl8139 131 132 132 133 RD_DRV_CFG = -
contrib/conf/net-qe.sh
r3819ce5 recf823a 10 10 qemu $@ -device e1000,vlan=0 -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso 11 11 ;; 12 rtl8139) 13 shift 14 qemu $@ -device rtl8139,vlan=0 -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso 15 ;; 12 16 *) 13 echo "Usage: $0 {ne2k|e1k }"17 echo "Usage: $0 {ne2k|e1k|rtl8139}" 14 18 esac -
uspace/Makefile
r3819ce5 recf823a 122 122 drv/nic/lo \ 123 123 drv/nic/ne2k \ 124 drv/nic/e1k 124 drv/nic/e1k \ 125 drv/nic/rtl8139 125 126 126 127 ifeq ($(CONFIG_PCC),y) -
uspace/app/websrv/websrv.c
r3819ce5 recf823a 49 49 50 50 #define PORT_NUMBER 8080 51 #define BACKLOG_SIZE 3 51 52 52 53 #define WEB_ROOT "/data/web" … … 275 276 } 276 277 277 rc = listen(listen_sd, 1);278 rc = listen(listen_sd, BACKLOG_SIZE); 278 279 if (rc != EOK) { 279 280 printf("Error calling listen() (%d).\n", rc); -
uspace/dist/data/web/index.htm
r3819ce5 recf823a 7 7 <body> 8 8 <h1>Hello from HelenOS!</h1> 9 <img src="helenos.png" alt="" style="float: left; margin: 6px;"> 9 10 <p> 10 11 This web page is brought to you by courtesy of HelenOS web server -
uspace/drv/bus/usb/ohci/root_hub.c
r3819ce5 recf823a 226 226 fibril_mutex_lock(&instance->guard); 227 227 assert(instance->unfinished_interrupt_transfer == NULL); 228 constuint16_t mask = create_interrupt_mask(instance);228 uint16_t mask = create_interrupt_mask(instance); 229 229 if (mask == 0) { 230 230 usb_log_debug("No changes...\n"); … … 257 257 if (instance->unfinished_interrupt_transfer) { 258 258 usb_log_debug("Finalizing interrupt transfer\n"); 259 constuint16_t mask = create_interrupt_mask(instance);259 uint16_t mask = create_interrupt_mask(instance); 260 260 interrupt_request(instance->unfinished_interrupt_transfer, 261 261 mask, instance->interrupt_mask_size); … … 278 278 279 279 /* 7 bytes + 2 port bit fields (port count + global bit) */ 280 constsize_t size = 7 + (instance->interrupt_mask_size * 2);280 size_t size = 7 + (instance->interrupt_mask_size * 2); 281 281 assert(size <= HUB_DESCRIPTOR_MAX_SIZE); 282 282 instance->hub_descriptor_size = size; 283 283 284 constuint32_t hub_desc = instance->registers->rh_desc_a;285 constuint32_t port_desc = instance->registers->rh_desc_b;284 uint32_t hub_desc = instance->registers->rh_desc_a; 285 uint32_t port_desc = instance->registers->rh_desc_b; 286 286 287 287 /* bDescLength */ … … 394 394 395 395 396 constusb_device_request_setup_packet_t *request_packet =396 usb_device_request_setup_packet_t *request_packet = 397 397 (usb_device_request_setup_packet_t*)request->setup_buffer; 398 398 … … 406 406 TRANSFER_END(request, EOVERFLOW); 407 407 } else { 408 constuint32_t data = instance->registers->rh_status &408 uint32_t data = instance->registers->rh_status & 409 409 (RHS_LPS_FLAG | RHS_LPSC_FLAG 410 410 | RHS_OCI_FLAG | RHS_OCIC_FLAG); … … 420 420 TRANSFER_END(request, EOVERFLOW); 421 421 } else { 422 constunsigned port = request_packet->index;422 unsigned port = request_packet->index; 423 423 if (port < 1 || port > instance->port_count) 424 424 TRANSFER_END(request, EINVAL); 425 425 426 constuint32_t data =426 uint32_t data = 427 427 instance->registers->rh_port_status[port - 1]; 428 428 TRANSFER_END_DATA(request, &data, sizeof(data)); … … 434 434 TRANSFER_END(request, EOVERFLOW); 435 435 } else { 436 static constuint16_t data =436 uint16_t data = 437 437 uint16_host2usb(USB_DEVICE_STATUS_SELF_POWERED); 438 438 TRANSFER_END_DATA(request, &data, sizeof(data)); … … 455 455 } else { 456 456 /* Endpoints are OK. (We don't halt) */ 457 static constuint16_t data = 0;457 uint16_t data = 0; 458 458 TRANSFER_END_DATA(request, &data, sizeof(data)); 459 459 } … … 480 480 assert(request); 481 481 482 constusb_device_request_setup_packet_t *setup_request =482 usb_device_request_setup_packet_t *setup_request = 483 483 (usb_device_request_setup_packet_t *) request->setup_buffer; 484 constuint16_t setup_request_value = setup_request->value_high;484 uint16_t setup_request_value = setup_request->value_high; 485 485 switch (setup_request_value) 486 486 { … … 648 648 assert(request); 649 649 650 constusb_device_request_setup_packet_t *setup_request =650 usb_device_request_setup_packet_t *setup_request = 651 651 (usb_device_request_setup_packet_t *) request->setup_buffer; 652 652 switch (setup_request->request_type) … … 654 654 case USB_HUB_REQ_TYPE_SET_PORT_FEATURE: 655 655 usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n"); 656 constint ret = set_feature_port(instance,656 int ret = set_feature_port(instance, 657 657 setup_request->value, setup_request->index); 658 658 TRANSFER_END(request, ret); … … 686 686 assert(request); 687 687 688 constusb_device_request_setup_packet_t *setup_request =688 usb_device_request_setup_packet_t *setup_request = 689 689 (usb_device_request_setup_packet_t *) request->setup_buffer; 690 690 … … 693 693 case USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE: 694 694 usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE\n"); 695 constint ret = clear_feature_port(instance,695 int ret = clear_feature_port(instance, 696 696 setup_request->value, setup_request->index); 697 697 TRANSFER_END(request, ret); … … 753 753 usb_log_debug2("CTRL packet: %s.\n", 754 754 usb_debug_str_buffer((uint8_t *) request->setup_buffer, 8, 8)); 755 constusb_device_request_setup_packet_t *setup_request =755 usb_device_request_setup_packet_t *setup_request = 756 756 (usb_device_request_setup_packet_t *) request->setup_buffer; 757 757 switch (setup_request->request) … … 771 771 if (request->buffer_size == 0) 772 772 TRANSFER_END(request, EOVERFLOW); 773 static constuint8_t config = 1;773 uint8_t config = 1; 774 774 TRANSFER_END_DATA(request, &config, sizeof(config)); 775 775 -
uspace/drv/infrastructure/rootmac/rootmac.c
r3819ce5 recf823a 161 161 162 162 static hw_res_ops_t fun_hw_res_ops = { 163 164 &rootmac_enable_interrupt163 .get_resource_list = &rootmac_get_resources, 164 .enable_interrupt = &rootmac_enable_interrupt 165 165 }; 166 166 -
uspace/drv/nic/rtl8139/defs.c
r3819ce5 recf823a 27 27 */ 28 28 29 #include " rtl8139_defs.h"29 #include "defs.h" 30 30 31 31 const char* model_names[RTL8139_VER_COUNT] = { -
uspace/drv/nic/rtl8139/driver.c
r3819ce5 recf823a 33 33 #include <libarch/ddi.h> 34 34 #include <libarch/barrier.h> 35 #include <nlog.h> 36 37 #include <d ma.h>35 36 #include <as.h> 37 #include <ddf/log.h> 38 38 #include <ddf/interrupt.h> 39 #include < devman.h>39 #include <io/log.h> 40 40 #include <nic.h> 41 41 #include <packet_client.h> … … 50 50 #include <str.h> 51 51 52 #include " rtl8139_defs.h"53 #include " rtl8139_driver.h"54 #include " rtl8139_general.h"52 #include "defs.h" 53 #include "driver.h" 54 #include "general.h" 55 55 56 56 /** Global mutex for work with shared irq structure */ … … 164 164 (RXBUF_SIZE_FLAGS << RCR_RBLEN_SHIFT); 165 165 166 nlog_debug("Rewriting rcr: %x -> %x", pio_read_32(rtl8139->io_port + RCR),166 ddf_msg(LVL_DEBUG, "Rewriting rcr: %x -> %x", pio_read_32(rtl8139->io_port + RCR), 167 167 rcr); 168 168 … … 373 373 static ddf_dev_ops_t rtl8139_dev_ops; 374 374 375 static int rtl8139_ add_device(ddf_dev_t *dev);375 static int rtl8139_dev_add(ddf_dev_t *dev); 376 376 377 377 /** Basic driver operations for RTL8139 driver */ 378 378 static driver_ops_t rtl8139_driver_ops = { 379 . add_device = &rtl8139_add_device,379 .dev_add = &rtl8139_dev_add, 380 380 }; 381 381 … … 409 409 rtl8139_t *rtl8139 = nic_get_specific(nic_data); 410 410 assert(rtl8139); 411 nlog_debug("Sending packet");411 ddf_msg(LVL_DEBUG, "Sending packet"); 412 412 413 413 /* Get the packet data and check if it can be send */ … … 418 418 419 419 if ((packet_length > RTL8139_PACKET_MAX_LENGTH) || !packet_data) { 420 nlog_error("Write packet length error: data %p, length %z",420 ddf_msg(LVL_ERROR, "Write packet length error: data %p, length %z", 421 421 packet_data, packet_length); 422 422 nic_report_send_error(rtl8139->nic_data, NIC_SEC_OTHER, 1); … … 527 527 nic_frame_t *frame = nic_alloc_frame(nic_data, packet_size); 528 528 if (! frame) { 529 nlog_error("Can not allocate frame for received packet.");529 ddf_msg(LVL_ERROR, "Can not allocate frame for received packet."); 530 530 return NULL; 531 531 } … … 533 533 void *packet_data = packet_suffix(frame->packet, packet_size); 534 534 if (!packet_data) { 535 nlog_error("Can not get the packet suffix.");535 ddf_msg(LVL_ERROR, "Can not get the packet suffix."); 536 536 nic_release_frame(nic_data, frame); 537 537 return NULL; … … 564 564 pio_write_32(rtl8139->io_port + CAPR, 0); 565 565 pio_write_32(rtl8139->io_port + RBSTART, 566 PTR2U32(rtl8139->rx_buff .physical));566 PTR2U32(rtl8139->rx_buff_phys)); 567 567 568 568 write_barrier(); … … 588 588 nic_frame_list_t *frames = nic_alloc_frame_list(); 589 589 if (!frames) 590 nlog_error("Can not allocate frame list for received packets.");591 592 void *rx_buffer = rtl8139->rx_buff .virtual;590 ddf_msg(LVL_ERROR, "Can not allocate frame list for received packets."); 591 592 void *rx_buffer = rtl8139->rx_buff_virt; 593 593 594 594 /* where to start reading */ … … 620 620 if (size == RTL8139_EARLY_SIZE) { 621 621 /* The packet copying is still in progress, break receiving */ 622 nlog_debug("Early threshold reached, not completely coppied");622 ddf_msg(LVL_DEBUG, "Early threshold reached, not completely coppied"); 623 623 break; 624 624 } … … 626 626 /* Check if the header is valid, otherwise we are lost in the buffer */ 627 627 if (size == 0 || size > RTL8139_PACKET_MAX_LENGTH) { 628 nlog_error("Receiver error -> receiver reset (size: %4"PRIu16", "628 ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (size: %4"PRIu16", " 629 629 "header 0x%4"PRIx16". Offset: %zu)", size, packet_header, 630 630 rx_offset); … … 632 632 } 633 633 if (size < RTL8139_RUNT_MAX_SIZE && !(rcs & RSR_RUNT)) { 634 nlog_error("Receiver error -> receiver reset (%"PRIx16")", size);634 ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (%"PRIx16")", size); 635 635 goto rx_err; 636 636 } … … 801 801 pio_write_32(rtl8139->io_port + TIMERINT, timer_val); 802 802 pio_write_32(rtl8139->io_port + TCTR, 0x0); 803 nlog_debug("rtl8139 timer: %"PRIu32"\treceive: %d", timer_val, receive);803 ddf_msg(LVL_DEBUG, "rtl8139 timer: %"PRIu32"\treceive: %d", timer_val, receive); 804 804 return receive; 805 805 } … … 925 925 /* Write transmittion buffer addresses */ 926 926 for(i = 0; i < TX_BUFF_COUNT; ++i) { 927 uint32_t addr = PTR2U32(rtl8139->tx_buff_ mem.physical+ i*TX_BUFF_SIZE);927 uint32_t addr = PTR2U32(rtl8139->tx_buff_phys + i*TX_BUFF_SIZE); 928 928 pio_write_32(io_base + TSAD0 + 4*i, addr); 929 929 } … … 932 932 nic_set_tx_busy(rtl8139->nic_data, 0); 933 933 934 pio_write_32(io_base + RBSTART, PTR2U32(rtl8139->rx_buff .physical));934 pio_write_32(io_base + RBSTART, PTR2U32(rtl8139->rx_buff_phys)); 935 935 936 936 /* Enable transmitter and receiver */ … … 949 949 { 950 950 assert(nic_data); 951 nlog_info("Activating device");951 ddf_msg(LVL_NOTE, "Activating device"); 952 952 953 953 rtl8139_t *rtl8139 = nic_get_specific(nic_data); … … 962 962 nic_enable_interrupt(nic_data, rtl8139->irq); 963 963 964 nlog_debug("Device activated, interrupt %d registered", rtl8139->irq);964 ddf_msg(LVL_DEBUG, "Device activated, interrupt %d registered", rtl8139->irq); 965 965 return EOK; 966 966 } … … 1079 1079 1080 1080 if (hw_resources->irqs.count != 1) { 1081 nlog_error("%s device: unexpected irq count", dev->name);1081 ddf_msg(LVL_ERROR, "%s device: unexpected irq count", dev->name); 1082 1082 return EINVAL; 1083 1083 }; 1084 1084 if (hw_resources->io_ranges.count != 1) { 1085 nlog_error("%s device: unexpected io ranges count", dev->name);1085 ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", dev->name); 1086 1086 return EINVAL; 1087 1087 } 1088 1088 1089 1089 rtl8139->irq = hw_resources->irqs.irqs[0]; 1090 nlog_debug("%s device: irq 0x%x assigned", dev->name, rtl8139->irq);1090 ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", dev->name, rtl8139->irq); 1091 1091 1092 1092 rtl8139->io_addr = IOADDR_TO_PTR(hw_resources->io_ranges.ranges[0].address); 1093 1093 if (hw_resources->io_ranges.ranges[0].size < RTL8139_IO_SIZE) { 1094 nlog_error("i/o range assigned to the device "1094 ddf_msg(LVL_ERROR, "i/o range assigned to the device " 1095 1095 "%s is too small.", dev->name); 1096 1096 return EINVAL; 1097 1097 } 1098 nlog_debug("%s device: i/o addr %p assigned.", dev->name, rtl8139->io_addr);1098 ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", dev->name, rtl8139->io_addr); 1099 1099 1100 1100 return EOK; … … 1142 1142 static int rtl8139_buffers_create(rtl8139_t *rtl8139) 1143 1143 { 1144 assert(rtl8139);1145 1144 size_t i = 0; 1146 1145 int rc; 1147 1146 1148 nlog_debug("Creating buffers"); 1149 1150 rtl8139->tx_buff_mem.size = TX_PAGES; 1151 rtl8139->tx_buff_mem.mapping_flags = AS_AREA_WRITE; 1152 rc = dma_allocate_anonymous(&rtl8139->tx_buff_mem, DMA_32_BITS); 1147 ddf_msg(LVL_DEBUG, "Creating buffers"); 1148 1149 rc = dmamem_map_anonymous(TX_PAGES * PAGE_SIZE, AS_AREA_WRITE, 0, 1150 &rtl8139->tx_buff_phys, &rtl8139->tx_buff_virt); 1153 1151 if (rc != EOK) { 1154 nlog_error("Can not allocate transmitter buffers.");1152 ddf_msg(LVL_ERROR, "Can not allocate transmitter buffers."); 1155 1153 goto err_tx_alloc; 1156 1154 } 1157 1155 1158 for (i = 0; i < TX_BUFF_COUNT; ++i)1159 rtl8139->tx_buff[i] = rtl8139->tx_buff_ mem.virtual+ i * TX_BUFF_SIZE;1160 1161 nlog_debug("The transmittion buffers allocated");1156 for (i = 0; i < TX_BUFF_COUNT; ++i) 1157 rtl8139->tx_buff[i] = rtl8139->tx_buff_virt + i * TX_BUFF_SIZE; 1158 1159 ddf_msg(LVL_DEBUG, "The transmittion buffers allocated"); 1162 1160 1163 1161 /* Use the first buffer for next transmittion */ … … 1166 1164 1167 1165 /* Allocate buffer for receiver */ 1168 size_t rx_pages = ALIGN_UP(RxBUF_TOT_LENGTH, PAGE_SIZE) / PAGE_SIZE; 1169 nlog_debug("Allocating receiver buffer of the size %zd pages", rx_pages); 1170 1171 rtl8139->rx_buff.size = rx_pages; 1172 rtl8139->rx_buff.mapping_flags = AS_AREA_READ; 1173 rc = dma_allocate_anonymous(&rtl8139->rx_buff, DMA_32_BITS); 1174 if( rc != EOK ) { 1175 nlog_error("Can not allocate receiver buffer."); 1166 ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %zu bytes", 1167 RxBUF_TOT_LENGTH); 1168 1169 rc = dmamem_map_anonymous(RxBUF_TOT_LENGTH, AS_AREA_READ, 0, 1170 &rtl8139->rx_buff_phys, &rtl8139->rx_buff_virt); 1171 if (rc != EOK) { 1172 ddf_msg(LVL_ERROR, "Can not allocate receive buffer."); 1176 1173 goto err_rx_alloc; 1177 1174 } 1178 nlog_debug("The buffers created");1175 ddf_msg(LVL_DEBUG, "The buffers created"); 1179 1176 1180 1177 return EOK; 1181 1178 1182 1179 err_rx_alloc: 1183 dma _free(&rtl8139->tx_buff_mem);1180 dmamem_unmap_anonymous(&rtl8139->tx_buff_virt); 1184 1181 err_tx_alloc: 1185 1182 return rc; … … 1194 1191 static int rtl8139_device_initialize(ddf_dev_t *dev) 1195 1192 { 1196 nlog_debug("rtl8139_dev_initialize %s", dev->name);1193 ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", dev->name); 1197 1194 1198 1195 int ret = EOK; 1199 1196 1200 nlog_debug("rtl8139: creating device data");1197 ddf_msg(LVL_DEBUG, "rtl8139: creating device data"); 1201 1198 1202 1199 /* Allocate driver data for the device. */ 1203 1200 rtl8139_t *rtl8139 = rtl8139_create_dev_data(dev); 1204 1201 if (rtl8139 == NULL) { 1205 nlog_error("Not enough memory for initializing %s.", dev->name);1202 ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", dev->name); 1206 1203 return ENOMEM; 1207 1204 } 1208 1205 1209 nlog_debug("rtl8139: dev_data created");1206 ddf_msg(LVL_DEBUG, "rtl8139: dev_data created"); 1210 1207 1211 1208 /* Obtain and fill hardware resources info and connect to parent */ 1212 1209 ret = rtl8139_get_resource_info(dev); 1213 1210 if (ret != EOK) { 1214 nlog_error("Can not obatin hw resources information");1211 ddf_msg(LVL_ERROR, "Can not obatin hw resources information"); 1215 1212 goto failed; 1216 1213 } 1217 1214 1218 nlog_debug("rtl8139: resource_info obtained");1215 ddf_msg(LVL_DEBUG, "rtl8139: resource_info obtained"); 1219 1216 1220 1217 /* Allocate DMA buffers */ … … 1231 1228 rtl8139->rcr_data.rcr_base = (0x8 << RCR_ERTH_SHIFT); 1232 1229 1233 nlog_debug("The device is initialized");1230 ddf_msg(LVL_DEBUG, "The device is initialized"); 1234 1231 return ret; 1235 1232 1236 1233 failed: 1237 nlog_error("The device initialization failed");1234 ddf_msg(LVL_ERROR, "The device initialization failed"); 1238 1235 rtl8139_dev_cleanup(dev); 1239 1236 return ret; … … 1248 1245 static int rtl8139_pio_enable(ddf_dev_t *dev) 1249 1246 { 1250 nlog_debug(NAME ": rtl8139_pio_enable %s", dev->name);1247 ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", dev->name); 1251 1248 1252 1249 rtl8139_t *rtl8139 = nic_get_specific(nic_get_from_ddf_dev(dev)); … … 1254 1251 /* Gain control over port's registers. */ 1255 1252 if (pio_enable(rtl8139->io_addr, RTL8139_IO_SIZE, &rtl8139->io_port)) { 1256 nlog_error("Cannot gain the port %lx for device %s.", rtl8139->io_addr,1253 ddf_msg(LVL_ERROR, "Cannot gain the port %lx for device %s.", rtl8139->io_addr, 1257 1254 dev->name); 1258 1255 return EADDRNOTAVAIL; … … 1282 1279 if (rtl8139_versions[i].hwverid == hwverid) { 1283 1280 rtl8139->hw_version = rtl8139_versions[i].ver_id; 1284 nlog_info("HW version found: index %zu, ver_id %d (%s)", i,1281 ddf_msg(LVL_NOTE, "HW version found: index %zu, ver_id %d (%s)", i, 1285 1282 rtl8139_versions[i].ver_id, model_names[rtl8139->hw_version]); 1286 1283 } … … 1296 1293 * @return EOK if added successfully, negative error code otherwise 1297 1294 */ 1298 int rtl8139_ add_device(ddf_dev_t *dev)1295 int rtl8139_dev_add(ddf_dev_t *dev) 1299 1296 { 1300 1297 assert(dev); 1301 nlog_info("RTL8139_add_device%s (handle = %d)", dev->name, dev->handle);1298 ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %d)", dev->name, dev->handle); 1302 1299 1303 1300 /* Init device structure for rtl8139 */ … … 1330 1327 rc = nic_connect_to_services(nic_data); 1331 1328 if (rc != EOK) { 1332 nlog_error("Failed to connect to services", rc);1329 ddf_msg(LVL_ERROR, "Failed to connect to services", rc); 1333 1330 goto err_irq; 1334 1331 } … … 1336 1333 rc = nic_register_as_ddf_fun(nic_data, &rtl8139_dev_ops); 1337 1334 if (rc != EOK) { 1338 nlog_error("Failed to register as DDF function - error %d", rc);1335 ddf_msg(LVL_ERROR, "Failed to register as DDF function - error %d", rc); 1339 1336 goto err_irq; 1340 1337 } 1341 1338 1342 nlog_info("The %s device has been successfully initialized.",1339 ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.", 1343 1340 dev->name); 1344 1341 … … 1581 1578 1582 1579 if (allow_send && time > 0) { 1583 nlog_warning("Time setting is not supported in set_pause method.");1580 ddf_msg(LVL_WARN, "Time setting is not supported in set_pause method."); 1584 1581 } 1585 1582 return EOK; … … 2121 2118 pio_write_32(rtl8139->io_port + TCTR, 0); 2122 2119 2123 nlog_debug("Periodic mode. Interrupt mask %"PRIx16", poll.full_skips %"2120 ddf_msg(LVL_DEBUG, "Periodic mode. Interrupt mask %"PRIx16", poll.full_skips %" 2124 2121 PRIu32", last timer %"PRIu32".", rtl8139->int_mask, 2125 2122 rtl8139->poll_timer.full_skips, rtl8139->poll_timer.last_val); … … 2168 2165 &rtl8139_driver_ops, &rtl8139_dev_ops, &rtl8139_nic_iface); 2169 2166 2170 nlog_set_min_severity(DEBUG);2171 nlog_info("HelenOS RTL8139 driver started");2167 ddf_log_init(NAME, LVL_ERROR); 2168 ddf_msg(LVL_NOTE, "HelenOS RTL8139 driver started"); 2172 2169 return ddf_driver_main(&rtl8139_driver); 2173 2170 } -
uspace/drv/nic/rtl8139/driver.h
r3819ce5 recf823a 30 30 #define RTL8139_DRIVER_H_ 31 31 32 #include " rtl8139_defs.h"33 #include " rtl8139_general.h"32 #include "defs.h" 33 #include "general.h" 34 34 #include <sys/types.h> 35 35 #include <stdint.h> 36 #include <dma.h>37 36 38 37 /** The driver name */ … … 97 96 * Each buffer takes 2kB 98 97 */ 99 dma_mem_t tx_buff_mem; 98 void *tx_buff_phys; 99 void *tx_buff_virt; 100 100 101 /** Virtual adresses of the Tx buffers */ 101 102 void *tx_buff[TX_BUFF_COUNT]; … … 112 113 113 114 /** Buffer for receiving packets */ 114 dma_mem_t rx_buff; 115 void *rx_buff_phys; 116 void *rx_buff_virt; 115 117 116 118 /** Receiver control register data */ -
uspace/drv/nic/rtl8139/general.c
r3819ce5 recf823a 32 32 */ 33 33 34 #include " rtl8139_general.h"34 #include "general.h" 35 35 36 36 #include <mem.h> -
uspace/srv/net/tl/tcp/conn.c
r3819ce5 recf823a 121 121 fibril_condvar_initialize(&conn->cstate_cv); 122 122 123 conn->cstate_cb = NULL; 124 123 125 conn->cstate = st_listen; 124 126 conn->reset = false; … … 243 245 tcp_cstate_t old_state; 244 246 247 log_msg(LVL_DEBUG, "tcp_conn_state_set(%p)", conn); 248 245 249 old_state = conn->cstate; 246 250 conn->cstate = nstate; 247 251 fibril_condvar_broadcast(&conn->cstate_cv); 252 253 /* Run user callback function */ 254 if (conn->cstate_cb != NULL) { 255 log_msg(LVL_DEBUG, "tcp_conn_state_set() - run user CB"); 256 conn->cstate_cb(conn, conn->cstate_cb_arg); 257 } else { 258 log_msg(LVL_DEBUG, "tcp_conn_state_set() - no user CB"); 259 } 248 260 249 261 assert(old_state != st_closed); -
uspace/srv/net/tl/tcp/sock.c
r3819ce5 recf823a 52 52 #define FRAGMENT_SIZE 1024 53 53 54 #define MAX_BACKLOG 128 55 54 56 /** Free ports pool start. */ 55 57 #define TCP_FREE_PORTS_START 1025 … … 60 62 static int last_used_port = TCP_FREE_PORTS_START - 1; 61 63 static socket_ports_t gsock; 64 65 static void tcp_sock_cstate_cb(tcp_conn_t *conn, void *arg); 62 66 63 67 void tcp_sock_init(void) … … 95 99 { 96 100 tcp_sockdata_t *sock; 101 socket_core_t *sock_core; 97 102 int sock_id; 98 103 int rc; … … 106 111 } 107 112 113 fibril_mutex_initialize(&sock->lock); 108 114 sock->client = client; 109 115 sock->laddr.ipv4 = TCP_IPV4_ANY; 116 sock->lconn = NULL; 117 sock->backlog = 0; 118 list_initialize(&sock->ready); 110 119 111 120 sock_id = SOCKET_GET_SOCKET_ID(call); … … 115 124 return; 116 125 } 126 127 sock_core = socket_cores_find(&client->sockets, sock_id); 128 assert(sock_core != NULL); 129 sock->sock_core = sock_core; 117 130 118 131 refresh_answer(&answer, NULL); … … 167 180 socket_core_t *sock_core; 168 181 tcp_sockdata_t *socket; 182 tcp_error_t trc; 183 tcp_sock_t lsocket; 184 tcp_sock_t fsocket; 185 tcp_conn_t *conn; 186 tcp_sock_lconn_t *lconn; 187 int i; 169 188 170 189 log_msg(LVL_DEBUG, "tcp_sock_listen()"); … … 177 196 return; 178 197 } 198 199 if (backlog > MAX_BACKLOG) 200 backlog = MAX_BACKLOG; 179 201 180 202 sock_core = socket_cores_find(&client->sockets, socket_id); … … 187 209 188 210 /* 189 * XXX We do not do anything and defer action to accept(). 190 * This is a slight difference in semantics, but most servers 191 * would just listen() and immediately accept() in a loop. 192 * 193 * The only difference is that there is a window between 194 * listen() and accept() or two accept()s where we refuse 195 * connections. 211 * Prepare @c backlog listening connections. 196 212 */ 197 (void)backlog; 198 (void)socket; 199 213 fibril_mutex_lock(&socket->lock); 214 215 socket->backlog = backlog; 216 socket->lconn = calloc(sizeof(tcp_conn_t *), backlog); 217 if (socket->lconn == NULL) { 218 fibril_mutex_unlock(&socket->lock); 219 async_answer_0(callid, ENOMEM); 220 return; 221 } 222 223 log_msg(LVL_DEBUG, " - open connections"); 224 225 lsocket.addr.ipv4 = TCP_IPV4_ANY; 226 lsocket.port = sock_core->port; 227 fsocket.addr.ipv4 = TCP_IPV4_ANY; 228 fsocket.port = TCP_PORT_ANY; 229 230 for (i = 0; i < backlog; i++) { 231 232 lconn = calloc(sizeof(tcp_sock_lconn_t), 1); 233 if (lconn == NULL) { 234 /* XXX Clean up */ 235 fibril_mutex_unlock(&socket->lock); 236 async_answer_0(callid, ENOMEM); 237 return; 238 } 239 240 trc = tcp_uc_open(&lsocket, &fsocket, ap_passive, 241 tcp_open_nonblock, &conn); 242 if (conn == NULL) { 243 /* XXX Clean up */ 244 fibril_mutex_unlock(&socket->lock); 245 async_answer_0(callid, ENOMEM); 246 return; 247 } 248 249 tcp_uc_set_cstate_cb(conn, tcp_sock_cstate_cb, lconn); 250 251 assert(trc == TCP_EOK); 252 conn->name = (char *)"S"; 253 254 lconn->conn = conn; 255 lconn->socket = socket; 256 link_initialize(&lconn->ready_list); 257 socket->lconn[i] = lconn; 258 } 259 260 fibril_mutex_unlock(&socket->lock); 200 261 async_answer_0(callid, EOK); 201 log_msg(LVL_DEBUG, "tcp_sock_listen(): notify data\n");202 /* Push one accept notification to client's queue */203 tcp_sock_notify_aconn(sock_core);204 262 } 205 263 … … 248 306 } 249 307 308 fibril_mutex_lock(&socket->lock); 309 250 310 if (socket->laddr.ipv4 == TCP_IPV4_ANY) { 251 311 /* Find route to determine local IP address. */ … … 254 314 (void **)&phdr, &phdr_len); 255 315 if (rc != EOK) { 316 fibril_mutex_unlock(&socket->lock); 256 317 async_answer_0(callid, rc); 257 318 log_msg(LVL_DEBUG, "tcp_transmit_connect: Failed to find route."); … … 269 330 fsocket.port = uint16_t_be2host(addr->sin_port); 270 331 271 trc = tcp_uc_open(&lsocket, &fsocket, ap_active, &socket->conn);332 trc = tcp_uc_open(&lsocket, &fsocket, ap_active, 0, &socket->conn); 272 333 273 334 if (socket->conn != NULL) 274 335 socket->conn->name = (char *)"C"; 336 337 fibril_mutex_unlock(&socket->lock); 275 338 276 339 switch (trc) { … … 305 368 tcp_sock_t fsocket; 306 369 tcp_conn_t *conn; 370 tcp_conn_t *rconn; 371 tcp_sock_lconn_t *lconn; 307 372 int rc; 308 373 … … 319 384 320 385 socket = (tcp_sockdata_t *)sock_core->specific_data; 386 fibril_mutex_lock(&socket->lock); 321 387 322 388 log_msg(LVL_DEBUG, " - verify socket->conn"); 323 389 if (socket->conn != NULL) { 390 fibril_mutex_unlock(&socket->lock); 324 391 async_answer_0(callid, EINVAL); 325 392 return; 326 393 } 327 394 328 log_msg(LVL_DEBUG, " - open connection"); 395 if (list_empty(&socket->ready)) { 396 fibril_mutex_unlock(&socket->lock); 397 async_answer_0(callid, ENOENT); 398 return; 399 } 400 401 lconn = list_get_instance(list_first(&socket->ready), 402 tcp_sock_lconn_t, ready_list); 403 list_remove(&lconn->ready_list); 404 405 conn = lconn->conn; 406 tcp_uc_set_cstate_cb(conn, NULL, NULL); 407 408 /* Replenish listening connection */ 329 409 330 410 lsocket.addr.ipv4 = TCP_IPV4_ANY; … … 333 413 fsocket.port = TCP_PORT_ANY; 334 414 335 trc = tcp_uc_open(&lsocket, &fsocket, ap_passive, &conn); 336 if (conn != NULL) 337 conn->name = (char *)"S"; 338 339 log_msg(LVL_DEBUG, " - decode TCP return code"); 340 341 switch (trc) { 342 case TCP_EOK: 343 rc = EOK; 344 break; 345 case TCP_ERESET: 346 rc = ECONNABORTED; 347 break; 348 default: 349 assert(false); 350 } 351 352 log_msg(LVL_DEBUG, " - check TCP return code"); 353 if (rc != EOK) { 354 async_answer_0(callid, rc); 355 return; 356 } 415 trc = tcp_uc_open(&lsocket, &fsocket, ap_passive, tcp_open_nonblock, 416 &rconn); 417 if (rconn == NULL) { 418 /* XXX Clean up */ 419 fibril_mutex_unlock(&socket->lock); 420 async_answer_0(callid, ENOMEM); 421 return; 422 } 423 424 tcp_uc_set_cstate_cb(rconn, tcp_sock_cstate_cb, lconn); 425 426 assert(trc == TCP_EOK); 427 rconn->name = (char *)"S"; 428 429 lconn->conn = rconn; 430 431 /* Allocate socket for accepted connection */ 357 432 358 433 log_msg(LVL_DEBUG, "tcp_sock_accept(): allocate asocket\n"); 359 434 asocket = calloc(sizeof(tcp_sockdata_t), 1); 360 435 if (asocket == NULL) { 436 fibril_mutex_unlock(&socket->lock); 361 437 async_answer_0(callid, ENOMEM); 362 438 return; 363 439 } 364 440 441 fibril_mutex_initialize(&asocket->lock); 365 442 asocket->client = client; 366 443 asocket->conn = conn; … … 369 446 rc = socket_create(&client->sockets, client->sess, asocket, &asock_id); 370 447 if (rc != EOK) { 448 fibril_mutex_unlock(&socket->lock); 371 449 async_answer_0(callid, rc); 372 450 return; … … 385 463 answer_call(callid, asock_core->socket_id, &answer, 3); 386 464 387 /* Push one accept notification to client's queue */388 tcp_sock_notify_aconn(sock_core);389 390 465 /* Push one fragment notification to client's queue */ 466 log_msg(LVL_DEBUG, "tcp_sock_accept(): notify data\n"); 391 467 tcp_sock_notify_data(asock_core); 392 log_msg(LVL_DEBUG, "tcp_sock_accept(): notify aconn\n");468 fibril_mutex_unlock(&socket->lock); 393 469 } 394 470 … … 419 495 420 496 socket = (tcp_sockdata_t *)sock_core->specific_data; 497 fibril_mutex_lock(&socket->lock); 498 421 499 if (socket->conn == NULL) { 500 fibril_mutex_unlock(&socket->lock); 422 501 async_answer_0(callid, ENOTCONN); 423 502 return; … … 426 505 for (index = 0; index < fragments; index++) { 427 506 if (!async_data_write_receive(&wcallid, &length)) { 507 fibril_mutex_unlock(&socket->lock); 428 508 async_answer_0(callid, EINVAL); 429 509 return; … … 435 515 rc = async_data_write_finalize(wcallid, buffer, length); 436 516 if (rc != EOK) { 517 fibril_mutex_unlock(&socket->lock); 437 518 async_answer_0(callid, rc); 438 519 return; … … 459 540 460 541 if (rc != EOK) { 542 fibril_mutex_unlock(&socket->lock); 461 543 async_answer_0(callid, rc); 462 544 return; … … 467 549 SOCKET_SET_DATA_FRAGMENT_SIZE(answer, FRAGMENT_SIZE); 468 550 answer_call(callid, EOK, &answer, 2); 551 fibril_mutex_unlock(&socket->lock); 469 552 } 470 553 … … 504 587 505 588 socket = (tcp_sockdata_t *)sock_core->specific_data; 589 fibril_mutex_lock(&socket->lock); 590 506 591 if (socket->conn == NULL) { 592 fibril_mutex_unlock(&socket->lock); 507 593 async_answer_0(callid, ENOTCONN); 508 594 return; … … 532 618 log_msg(LVL_DEBUG, "**** tcp_uc_receive -> %d", rc); 533 619 if (rc != EOK) { 620 fibril_mutex_unlock(&socket->lock); 534 621 async_answer_0(callid, rc); 535 622 return; … … 545 632 log_msg(LVL_DEBUG, "addr read receive"); 546 633 if (!async_data_read_receive(&rcallid, &addr_length)) { 634 fibril_mutex_unlock(&socket->lock); 547 635 async_answer_0(callid, EINVAL); 548 636 return; … … 555 643 rc = async_data_read_finalize(rcallid, &addr, addr_length); 556 644 if (rc != EOK) { 645 fibril_mutex_unlock(&socket->lock); 557 646 async_answer_0(callid, EINVAL); 558 647 return; … … 562 651 log_msg(LVL_DEBUG, "data read receive"); 563 652 if (!async_data_read_receive(&rcallid, &length)) { 653 fibril_mutex_unlock(&socket->lock); 564 654 async_answer_0(callid, EINVAL); 565 655 return; … … 580 670 /* Push one fragment notification to client's queue */ 581 671 tcp_sock_notify_data(sock_core); 672 fibril_mutex_unlock(&socket->lock); 582 673 } 583 674 … … 603 694 604 695 socket = (tcp_sockdata_t *)sock_core->specific_data; 696 fibril_mutex_lock(&socket->lock); 605 697 606 698 if (socket->conn != NULL) { 607 699 trc = tcp_uc_close(socket->conn); 608 700 if (trc != TCP_EOK && trc != TCP_ENOTEXIST) { 701 fibril_mutex_unlock(&socket->lock); 609 702 async_answer_0(callid, EBADF); 610 703 return; … … 623 716 tcp_free_sock_data); 624 717 if (rc != EOK) { 718 fibril_mutex_unlock(&socket->lock); 625 719 async_answer_0(callid, rc); 626 720 return; 627 721 } 628 722 723 fibril_mutex_unlock(&socket->lock); 629 724 async_answer_0(callid, EOK); 630 725 } … … 640 735 log_msg(LVL_DEBUG, "tcp_sock_setsockopt()"); 641 736 async_answer_0(callid, ENOTSUP); 737 } 738 739 /** Called when connection state changes. */ 740 static void tcp_sock_cstate_cb(tcp_conn_t *conn, void *arg) 741 { 742 tcp_conn_status_t cstatus; 743 tcp_sock_lconn_t *lconn = (tcp_sock_lconn_t *)arg; 744 tcp_sockdata_t *socket = lconn->socket; 745 746 log_msg(LVL_DEBUG, "tcp_sock_cstate_cb()"); 747 fibril_mutex_lock(&socket->lock); 748 assert(conn == lconn->conn); 749 750 tcp_uc_status(conn, &cstatus); 751 if (cstatus.cstate != st_established) { 752 fibril_mutex_unlock(&socket->lock); 753 return; 754 } 755 756 assert_link_not_used(&lconn->ready_list); 757 list_append(&lconn->ready_list, &socket->ready); 758 759 log_msg(LVL_DEBUG, "tcp_sock_cstate_cb(): notify accept"); 760 761 /* Push one accept notification to client's queue */ 762 tcp_sock_notify_aconn(socket->sock_core); 763 fibril_mutex_unlock(&socket->lock); 642 764 } 643 765 -
uspace/srv/net/tl/tcp/tcp_type.h
r3819ce5 recf823a 152 152 } acpass_t; 153 153 154 typedef struct tcp_conn { 154 typedef enum { 155 tcp_open_nonblock = 1 156 } tcp_open_flags_t; 157 158 typedef struct tcp_conn tcp_conn_t; 159 160 /** Connection state change callback function */ 161 typedef void (*tcp_cstate_cb_t)(tcp_conn_t *, void *); 162 163 /** Connection */ 164 struct tcp_conn { 155 165 char *name; 156 166 link_t link; 167 168 /** Connection state change callback function */ 169 tcp_cstate_cb_t cstate_cb; 170 /** Argument to @c cstate_cb */ 171 void *cstate_cb_arg; 157 172 158 173 /** Connection identification (local and foreign socket) */ … … 233 248 /** Initial receive sequence number */ 234 249 uint32_t irs; 235 } tcp_conn_t; 236 237 typedef struct { 238 unsigned dummy; 250 }; 251 252 /** Data returned by Status user call */ 253 typedef struct { 254 /** Connection state */ 255 tcp_cstate_t cstate; 239 256 } tcp_conn_status_t; 240 257 … … 314 331 } tcp_client_t; 315 332 316 typedef struct { 333 typedef struct tcp_sockdata { 334 /** Lock */ 335 fibril_mutex_t lock; 336 /** Socket core */ 337 socket_core_t *sock_core; 317 338 /** Client */ 318 339 tcp_client_t *client; … … 321 342 /** Local address */ 322 343 netaddr_t laddr; 344 /** Backlog size */ 345 int backlog; 346 /** Array of listening connections, @c backlog elements */ 347 struct tcp_sock_lconn **lconn; 348 /** List of connections (from lconn) that are ready to be accepted */ 349 list_t ready; 323 350 } tcp_sockdata_t; 351 352 typedef struct tcp_sock_lconn { 353 tcp_conn_t *conn; 354 tcp_sockdata_t *socket; 355 int index; 356 link_t ready_list; 357 } tcp_sock_lconn_t; 358 324 359 325 360 #endif -
uspace/srv/net/tl/tcp/test.c
r3819ce5 recf823a 62 62 fsock.addr.ipv4 = 0x7f000001; 63 63 printf("S: User open...\n"); 64 tcp_uc_open(&lsock, &fsock, ap_passive, &conn);64 tcp_uc_open(&lsock, &fsock, ap_passive, 0, &conn); 65 65 conn->name = (char *) "S"; 66 66 … … 102 102 async_usleep(1000*1000*3); 103 103 printf("C: User open...\n"); 104 tcp_uc_open(&lsock, &fsock, ap_active, &conn);104 tcp_uc_open(&lsock, &fsock, ap_active, 0, &conn); 105 105 conn->name = (char *) "C"; 106 106 -
uspace/srv/net/tl/tcp/ucall.c
r3819ce5 recf823a 53 53 * @param fsock Foreign socket 54 54 * @param acpass Active/passive 55 * @param oflags Open flags 55 56 * @param conn Connection 56 57 * … … 65 66 */ 66 67 tcp_error_t tcp_uc_open(tcp_sock_t *lsock, tcp_sock_t *fsock, acpass_t acpass, 67 tcp_ conn_t **conn)68 tcp_open_flags_t oflags, tcp_conn_t **conn) 68 69 { 69 70 tcp_conn_t *nconn; 70 71 71 log_msg(LVL_DEBUG, "tcp_uc_open(%p, %p, %s, % p)",72 log_msg(LVL_DEBUG, "tcp_uc_open(%p, %p, %s, %s, %p)", 72 73 lsock, fsock, acpass == ap_active ? "active" : "passive", 73 conn);74 oflags == tcp_open_nonblock ? "nonblock" : "none", conn); 74 75 75 76 nconn = tcp_conn_new(lsock, fsock); … … 79 80 /* Synchronize (initiate) connection */ 80 81 tcp_conn_sync(nconn); 82 } 83 84 if (oflags == tcp_open_nonblock) { 85 *conn = nconn; 86 return TCP_EOK; 81 87 } 82 88 … … 101 107 102 108 *conn = nconn; 109 log_msg(LVL_DEBUG, "tcp_uc_open -> %p", nconn); 103 110 return TCP_EOK; 104 111 } … … 258 265 { 259 266 log_msg(LVL_DEBUG, "tcp_uc_status()"); 267 cstatus->cstate = conn->cstate; 260 268 } 261 269 … … 270 278 log_msg(LVL_DEBUG, "tcp_uc_delete()"); 271 279 tcp_conn_delete(conn); 280 } 281 282 void tcp_uc_set_cstate_cb(tcp_conn_t *conn, tcp_cstate_cb_t cb, void *arg) 283 { 284 log_msg(LVL_DEBUG, "tcp_uc_set_ctate_cb(%p, %p, %p)", 285 conn, cb, arg); 286 287 conn->cstate_cb = cb; 288 conn->cstate_cb_arg = arg; 272 289 } 273 290 -
uspace/srv/net/tl/tcp/ucall.h
r3819ce5 recf823a 42 42 * User calls 43 43 */ 44 extern tcp_error_t tcp_uc_open(tcp_sock_t *, tcp_sock_t *, acpass_t, tcp_conn_t **); 44 extern tcp_error_t tcp_uc_open(tcp_sock_t *, tcp_sock_t *, acpass_t, 45 tcp_open_flags_t, tcp_conn_t **); 45 46 extern tcp_error_t tcp_uc_send(tcp_conn_t *, void *, size_t, xflags_t); 46 47 extern tcp_error_t tcp_uc_receive(tcp_conn_t *, void *, size_t, size_t *, xflags_t *); … … 49 50 extern void tcp_uc_status(tcp_conn_t *, tcp_conn_status_t *); 50 51 extern void tcp_uc_delete(tcp_conn_t *); 52 extern void tcp_uc_set_cstate_cb(tcp_conn_t *, tcp_cstate_cb_t, void *); 51 53 52 54 /*
Note:
See TracChangeset
for help on using the changeset viewer.