Changeset dffabf0 in mainline for uspace/srv
- Timestamp:
- 2011-01-05T19:08:03Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f03d3786
- Parents:
- e84d65a (diff), 196ef08 (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. - Location:
- uspace/srv
- Files:
-
- 1 added
- 2 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/ata_bd/ata_bd.c
re84d65a rdffabf0 65 65 #include <macros.h> 66 66 67 #include "ata_hw.h" 67 68 #include "ata_bd.h" 68 69 … … 70 71 #define NAMESPACE "bd" 71 72 73 /** Number of defined legacy controller base addresses. */ 74 #define LEGACY_CTLS 4 75 72 76 /** Physical block size. Should be always 512. */ 73 77 static const size_t block_size = 512; … … 77 81 78 82 /** I/O base address of the command registers. */ 79 static uintptr_t cmd_physical = 0x1f0;83 static uintptr_t cmd_physical; 80 84 /** I/O base address of the control registers. */ 81 static uintptr_t ctl_physical = 0x170; 85 static uintptr_t ctl_physical; 86 87 /** I/O base addresses for legacy (ISA-compatible) controllers. */ 88 static ata_base_t legacy_base[LEGACY_CTLS] = { 89 { 0x1f0, 0x3f0 }, 90 { 0x170, 0x370 }, 91 { 0x1e8, 0x3e8 }, 92 { 0x168, 0x368 } 93 }; 82 94 83 95 static ata_cmd_t *cmd; … … 87 99 static disk_t disk[MAX_DISKS]; 88 100 101 static void print_syntax(void); 89 102 static int ata_bd_init(void); 90 103 static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall); … … 110 123 int i, rc; 111 124 int n_disks; 125 unsigned ctl_num; 126 char *eptr; 112 127 113 128 printf(NAME ": ATA disk driver\n"); 114 129 115 printf("I/O address %p/%p\n", (void *) ctl_physical, 116 (void *) cmd_physical); 130 if (argc > 1) { 131 ctl_num = strtoul(argv[1], &eptr, 0); 132 if (*eptr != '\0' || ctl_num == 0 || ctl_num > 4) { 133 printf("Invalid argument.\n"); 134 print_syntax(); 135 return -1; 136 } 137 } else { 138 ctl_num = 1; 139 } 140 141 cmd_physical = legacy_base[ctl_num - 1].cmd; 142 ctl_physical = legacy_base[ctl_num - 1].ctl; 143 144 printf("I/O address %p/%p\n", (void *) cmd_physical, 145 (void *) ctl_physical); 117 146 118 147 if (ata_bd_init() != EOK) … … 139 168 continue; 140 169 141 snprintf(name, 16, "%s/ disk%d", NAMESPACE, i);170 snprintf(name, 16, "%s/ata%udisk%d", NAMESPACE, ctl_num, i); 142 171 rc = devmap_device_register(name, &disk[i].devmap_handle); 143 172 if (rc != EOK) { … … 160 189 /* Not reached */ 161 190 return 0; 191 } 192 193 194 static void print_syntax(void) 195 { 196 printf("Syntax: " NAME " <controller_number>\n"); 197 printf("Controller number = 1..4\n"); 162 198 } 163 199 -
uspace/srv/bd/ata_bd/ata_bd.h
re84d65a rdffabf0 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file ATA driver definitions. 33 33 */ 34 34 … … 40 40 #include <str.h> 41 41 42 enum { 43 CTL_READ_START = 0, 44 CTL_WRITE_START = 1, 45 }; 46 47 enum { 48 STATUS_FAILURE = 0 49 }; 50 51 enum { 52 MAX_DISKS = 2 53 }; 54 55 /** ATA Command Register Block. */ 56 typedef union { 57 /* Read/Write */ 58 struct { 59 uint16_t data_port; 60 uint8_t sector_count; 61 uint8_t sector_number; 62 uint8_t cylinder_low; 63 uint8_t cylinder_high; 64 uint8_t drive_head; 65 uint8_t pad_rw0; 66 }; 67 68 /* Read Only */ 69 struct { 70 uint8_t pad_ro0; 71 uint8_t error; 72 uint8_t pad_ro1[5]; 73 uint8_t status; 74 }; 75 76 /* Write Only */ 77 struct { 78 uint8_t pad_wo0; 79 uint8_t features; 80 uint8_t pad_wo1[5]; 81 uint8_t command; 82 }; 83 } ata_cmd_t; 84 85 typedef union { 86 /* Read */ 87 struct { 88 uint8_t pad0[6]; 89 uint8_t alt_status; 90 uint8_t drive_address; 91 }; 92 93 /* Write */ 94 struct { 95 uint8_t pad1[6]; 96 uint8_t device_control; 97 uint8_t pad2; 98 }; 99 } ata_ctl_t; 100 101 enum devctl_bits { 102 DCR_SRST = 0x04, /**< Software Reset */ 103 DCR_nIEN = 0x02 /**< Interrupt Enable (negated) */ 104 }; 105 106 enum status_bits { 107 SR_BSY = 0x80, /**< Busy */ 108 SR_DRDY = 0x40, /**< Drive Ready */ 109 SR_DWF = 0x20, /**< Drive Write Fault */ 110 SR_DSC = 0x10, /**< Drive Seek Complete */ 111 SR_DRQ = 0x08, /**< Data Request */ 112 SR_CORR = 0x04, /**< Corrected Data */ 113 SR_IDX = 0x02, /**< Index */ 114 SR_ERR = 0x01 /**< Error */ 115 }; 116 117 enum drive_head_bits { 118 DHR_LBA = 0x40, /**< Use LBA addressing mode */ 119 DHR_DRV = 0x10 /**< Select device 1 */ 120 }; 121 122 enum error_bits { 123 ER_BBK = 0x80, /**< Bad Block Detected */ 124 ER_UNC = 0x40, /**< Uncorrectable Data Error */ 125 ER_MC = 0x20, /**< Media Changed */ 126 ER_IDNF = 0x10, /**< ID Not Found */ 127 ER_MCR = 0x08, /**< Media Change Request */ 128 ER_ABRT = 0x04, /**< Aborted Command */ 129 ER_TK0NF = 0x02, /**< Track 0 Not Found */ 130 ER_AMNF = 0x01 /**< Address Mark Not Found */ 131 }; 132 133 enum ata_command { 134 CMD_READ_SECTORS = 0x20, 135 CMD_READ_SECTORS_EXT = 0x24, 136 CMD_WRITE_SECTORS = 0x30, 137 CMD_WRITE_SECTORS_EXT = 0x34, 138 CMD_IDENTIFY_DRIVE = 0xEC 139 }; 42 /** Base addresses for ATA I/O blocks. */ 43 typedef struct { 44 uintptr_t cmd; /**< Command block base address. */ 45 uintptr_t ctl; /**< Control block base address. */ 46 } ata_base_t; 140 47 141 48 /** Timeout definitions. Unit is 10 ms. */ … … 144 51 TIMEOUT_BSY = 100, /* 1 s */ 145 52 TIMEOUT_DRDY = 1000 /* 10 s */ 146 };147 148 /** Data returned from @c identify command. */149 typedef struct {150 uint16_t gen_conf;151 uint16_t cylinders;152 uint16_t _res2;153 uint16_t heads;154 uint16_t _vs4;155 uint16_t _vs5;156 uint16_t sectors;157 uint16_t _vs7;158 uint16_t _vs8;159 uint16_t _vs9;160 161 uint16_t serial_number[10];162 uint16_t _vs20;163 uint16_t _vs21;164 uint16_t vs_bytes;165 uint16_t firmware_rev[4];166 uint16_t model_name[20];167 168 uint16_t max_rw_multiple;169 uint16_t _res48;170 uint16_t caps;171 uint16_t _res50;172 uint16_t pio_timing;173 uint16_t dma_timing;174 175 uint16_t validity;176 uint16_t cur_cyl;177 uint16_t cur_heads;178 uint16_t cur_sectors;179 uint16_t cur_capacity0;180 uint16_t cur_capacity1;181 uint16_t mss;182 uint16_t total_lba28_0;183 uint16_t total_lba28_1;184 uint16_t sw_dma;185 uint16_t mw_dma;186 uint16_t pio_modes;187 uint16_t min_mw_dma_cycle;188 uint16_t rec_mw_dma_cycle;189 uint16_t min_raw_pio_cycle;190 uint16_t min_iordy_pio_cycle;191 192 uint16_t _res69;193 uint16_t _res70;194 uint16_t _res71;195 uint16_t _res72;196 uint16_t _res73;197 uint16_t _res74;198 199 uint16_t queue_depth;200 uint16_t _res76[1 + 79 - 76];201 uint16_t version_maj;202 uint16_t version_min;203 uint16_t cmd_set0;204 uint16_t cmd_set1;205 uint16_t csf_sup_ext;206 uint16_t csf_enabled0;207 uint16_t csf_enabled1;208 uint16_t csf_default;209 uint16_t udma;210 211 uint16_t _res89[1 + 99 - 89];212 213 /* Total number of blocks in LBA-48 addressing */214 uint16_t total_lba48_0;215 uint16_t total_lba48_1;216 uint16_t total_lba48_2;217 uint16_t total_lba48_3;218 219 /* Note: more fields are defined in ATA/ATAPI-7 */220 uint16_t _res104[1 + 127 - 104];221 uint16_t _vs128[1 + 159 - 128];222 uint16_t _res160[1 + 255 - 160];223 } identify_data_t;224 225 enum ata_caps {226 cap_iordy = 0x0800,227 cap_iordy_cbd = 0x0400,228 cap_lba = 0x0200,229 cap_dma = 0x0100230 };231 232 /** Bits of @c identify_data_t.cmd_set1 */233 enum ata_cs1 {234 cs1_addr48 = 0x0400 /**< 48-bit address feature set */235 53 }; 236 54 … … 269 87 } block_coord_t; 270 88 89 /** ATA device state structure. */ 271 90 typedef struct { 272 91 bool present; -
uspace/srv/hw/netif/dp8390/Makefile
re84d65a rdffabf0 39 39 -include $(CONFIG_MAKEFILE) 40 40 41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y)42 LIBS += $(USPACE_PREFIX)/srv/net/nil/eth/libeth.a43 endif44 45 41 BINARY = dp8390 46 42 -
uspace/srv/net/cfg/Makefile
re84d65a rdffabf0 36 36 -include $(CONFIG_MAKEFILE) 37 37 38 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 39 LO_SOURCE = lo.netif_nil_bundle 40 NE2K_SOURCE = ne2k.netif_nil_bundle 41 else 42 LO_SOURCE = lo.netif_standalone 43 NE2K_SOURCE = ne2k.netif_standalone 44 endif 38 LO_SOURCE = lo.netif_standalone 39 NE2K_SOURCE = ne2k.netif_standalone 45 40 46 41 LO_TARGET = lo -
uspace/srv/net/cfg/ne2k.netif_standalone
re84d65a rdffabf0 7 7 IL=ip 8 8 9 IRQ= 99 IRQ=5 10 10 IO=300 11 11 -
uspace/srv/net/netif/lo/Makefile
re84d65a rdffabf0 39 39 -include $(CONFIG_MAKEFILE) 40 40 41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y)42 LIBS += $(USPACE_PREFIX)/srv/net/nil/nildummy/libnildummy.a43 endif44 45 41 BINARY = lo 46 42 -
uspace/srv/net/nil/eth/Makefile
re84d65a rdffabf0 39 39 -include $(CONFIG_MAKEFILE) 40 40 41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 42 LIBRARY = libeth 43 else 44 BINARY = eth 45 endif 41 BINARY = eth 46 42 47 43 SOURCES = \ -
uspace/srv/net/nil/nildummy/Makefile
re84d65a rdffabf0 39 39 -include $(CONFIG_MAKEFILE) 40 40 41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 42 LIBRARY = libnildummy 43 else 44 BINARY = nildummy 45 endif 41 BINARY = nildummy 46 42 47 43 SOURCES = \ -
uspace/srv/net/tl/tcp/tcp.c
re84d65a rdffabf0 205 205 static int tcp_queue_received_packet(socket_core_t *, tcp_socket_data_t *, 206 206 packet_t *, int, size_t); 207 static void tcp_queue_received_end_of_data(socket_core_t *socket); 207 208 208 209 static int tcp_received_msg(device_id_t, packet_t *, services_t, services_t); … … 453 454 454 455 has_error_service: 455 fibril_rwlock_ read_unlock(&tcp_globals.lock);456 fibril_rwlock_write_unlock(&tcp_globals.lock); 456 457 457 458 /* TODO error reporting/handling */ … … 504 505 size_t offset; 505 506 uint32_t new_sequence_number; 507 bool forced_ack; 506 508 int rc; 507 509 … … 512 514 assert(packet); 513 515 516 forced_ack = false; 517 514 518 new_sequence_number = ntohl(header->sequence_number); 515 519 old_incoming = socket_data->next_incoming; 516 520 517 if (header->finalize) 518 socket_data->fin_incoming = new_sequence_number; 521 if (header->finalize) { 522 socket_data->fin_incoming = new_sequence_number + 523 total_length - TCP_HEADER_LENGTH(header); 524 } 519 525 520 526 /* Trim begining if containing expected data */ … … 760 766 /* Release duplicite or restricted */ 761 767 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 762 } 763 764 /* Change state according to the acknowledging incoming fin */ 765 if (IS_IN_INTERVAL_OVERFLOW(old_incoming, socket_data->fin_incoming, 766 socket_data->next_incoming)) { 768 forced_ack = true; 769 } 770 771 /* If next in sequence is an incoming FIN */ 772 if (socket_data->next_incoming == socket_data->fin_incoming) { 773 /* Advance sequence number */ 774 socket_data->next_incoming += 1; 775 776 /* Handle FIN */ 767 777 switch (socket_data->state) { 768 778 case TCP_SOCKET_FIN_WAIT_1: … … 771 781 socket_data->state = TCP_SOCKET_CLOSING; 772 782 break; 773 /*case TCP_ESTABLISHED:*/ 783 case TCP_SOCKET_ESTABLISHED: 784 /* Queue end-of-data marker on the socket. */ 785 tcp_queue_received_end_of_data(socket); 786 socket_data->state = TCP_SOCKET_CLOSE_WAIT; 787 break; 774 788 default: 775 789 socket_data->state = TCP_SOCKET_CLOSE_WAIT; … … 779 793 780 794 packet = tcp_get_packets_to_send(socket, socket_data); 781 if (!packet ) {795 if (!packet && (socket_data->next_incoming != old_incoming || forced_ack)) { 782 796 /* Create the notification packet */ 783 797 rc = tcp_create_notification_packet(&packet, socket, … … 835 849 836 850 return EOK; 851 } 852 853 /** Queue end-of-data marker on the socket. 854 * 855 * Next element in the sequence space is FIN. Queue end-of-data marker 856 * on the socket. 857 * 858 * @param socket Socket 859 */ 860 static void tcp_queue_received_end_of_data(socket_core_t *socket) 861 { 862 assert(socket != NULL); 863 864 /* Notify the destination socket */ 865 async_msg_5(socket->phone, NET_SOCKET_RECEIVED, 866 (sysarg_t) socket->socket_id, 867 0, 0, 0, 868 (sysarg_t) 0 /* 0 fragments == no more data */); 837 869 } 838 870 … … 1803 1835 fibril_rwlock_write_unlock(socket_data->local_lock); 1804 1836 1837 socket_data->state = TCP_SOCKET_SYN_SENT; 1838 1805 1839 /* Send the packet */ 1806 1840 printf("connecting %d\n", packet_get_id(packet)); … … 2210 2244 2211 2245 tcp_prepare_operation_header(socket, socket_data, header, 0, 0); 2212 rc = tcp_queue_packet(socket, socket_data, packet, 0);2246 rc = tcp_queue_packet(socket, socket_data, packet, total_length); 2213 2247 if (rc != EOK) 2214 2248 return rc; -
uspace/srv/vfs/vfs.h
re84d65a rdffabf0 34 34 #define VFS_VFS_H_ 35 35 36 #include <async.h> 36 37 #include <ipc/ipc.h> 37 38 #include <adt/list.h> … … 53 54 vfs_info_t vfs_info; 54 55 fs_handle_t fs_handle; 55 fibril_mutex_t phone_lock; 56 sysarg_t phone; 56 async_sess_t session; 57 57 } fs_info_t; 58 58 -
uspace/srv/vfs/vfs_register.c
re84d65a rdffabf0 39 39 #include <ipc/services.h> 40 40 #include <async.h> 41 #include <async_rel.h>42 41 #include <fibril.h> 43 42 #include <fibril_synch.h> … … 111 110 void vfs_register(ipc_callid_t rid, ipc_call_t *request) 112 111 { 112 int phone; 113 113 114 dprintf("Processing VFS_REGISTER request received from %p.\n", 114 115 request->in_phone_hash); … … 136 137 137 138 link_initialize(&fs_info->fs_link); 138 fibril_mutex_initialize(&fs_info->phone_lock);139 139 fs_info->vfs_info = *vfs_info; 140 140 free(vfs_info); … … 186 186 return; 187 187 } 188 fs_info->phone = IPC_GET_ARG5(call); 188 189 phone = IPC_GET_ARG5(call); 190 async_session_create(&fs_info->session, phone); 189 191 ipc_answer_0(callid, EOK); 190 192 … … 200 202 list_remove(&fs_info->fs_link); 201 203 fibril_mutex_unlock(&fs_head_lock); 202 ipc_hangup(fs_info->phone); 204 async_session_destroy(&fs_info->session); 205 ipc_hangup(phone); 203 206 free(fs_info); 204 207 ipc_answer_0(callid, EINVAL); … … 214 217 list_remove(&fs_info->fs_link); 215 218 fibril_mutex_unlock(&fs_head_lock); 216 ipc_hangup(fs_info->phone); 219 async_session_destroy(&fs_info->session); 220 ipc_hangup(phone); 217 221 free(fs_info); 218 222 ipc_answer_0(callid, EINVAL); … … 269 273 if (fs->fs_handle == handle) { 270 274 fibril_mutex_unlock(&fs_head_lock); 271 fibril_mutex_lock(&fs->phone_lock); 272 phone = async_relation_create(fs->phone); 273 fibril_mutex_unlock(&fs->phone_lock); 275 phone = async_exchange_begin(&fs->session); 274 276 275 277 assert(phone > 0); … … 295 297 if (fs->fs_handle == handle) { 296 298 fibril_mutex_unlock(&fs_head_lock); 297 fibril_mutex_lock(&fs->phone_lock); 298 async_relation_destroy(fs->phone, phone); 299 fibril_mutex_unlock(&fs->phone_lock); 299 async_exchange_end(&fs->session, phone); 300 300 return; 301 301 }
Note:
See TracChangeset
for help on using the changeset viewer.