Changes in / [9957a97:96cd5b4] in mainline
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/mm/frame.c
r9957a97 r96cd5b4 60 60 } else { 61 61 pfn_t conf = zone_external_conf_alloc(SIZE2FRAMES(size)); 62 if (conf != 0) 63 64 62 63 zone_create(ADDR2PFN(base), SIZE2FRAMES(size), conf, 64 ZONE_AVAILABLE | ZONE_HIGHMEM); 65 65 } 66 66 -
kernel/arch/ia32/src/mm/frame.c
r9957a97 r96cd5b4 79 79 } else { 80 80 conf = zone_external_conf_alloc(count); 81 if (conf != 0) 82 zone_create(pfn, count, conf, 83 ZONE_AVAILABLE | ZONE_HIGHMEM); 81 zone_create(pfn, count, conf, 82 ZONE_AVAILABLE | ZONE_HIGHMEM); 84 83 } 85 84 } else if ((e820table[i].type == MEMMAP_MEMORY_ACPI) || -
kernel/arch/ia64/src/mm/frame.c
r9957a97 r96cd5b4 79 79 ZONE_AVAILABLE | ZONE_LOWMEM); 80 80 } else { 81 pfn_t conf = zone_external_conf_alloc(count); 82 if (conf != 0) 83 zone_create(pfn, count, conf, 84 ZONE_AVAILABLE | ZONE_HIGHMEM); 81 pfn_t conf; 82 83 conf = zone_external_conf_alloc(count); 84 zone_create(pfn, count, conf, 85 ZONE_AVAILABLE | ZONE_HIGHMEM); 85 86 } 86 87 } -
kernel/arch/mips32/src/mm/frame.c
r9957a97 r96cd5b4 156 156 } else { 157 157 conf_frame = zone_external_conf_alloc(count); 158 if (conf_frame != 0)159 zone_create(first, count, conf_frame,160 ZONE_AVAILABLE | ZONE_HIGHMEM);161 }162 158 zone_create(first, count, conf_frame, 159 ZONE_AVAILABLE | ZONE_HIGHMEM); 160 } 161 162 163 163 if (phys_regions_count < MAX_REGIONS) { 164 164 phys_regions[phys_regions_count].start = first; -
kernel/arch/mips64/src/mm/frame.c
r9957a97 r96cd5b4 148 148 } else { 149 149 conf_frame = zone_external_conf_alloc(count); 150 if (conf_frame != 0)151 zone_create(first, count, conf_frame,152 ZONE_AVAILABLE | ZONE_HIGHMEM);153 }154 150 zone_create(first, count, conf_frame, 151 ZONE_AVAILABLE | ZONE_HIGHMEM); 152 } 153 154 155 155 if (phys_regions_count < MAX_REGIONS) { 156 156 phys_regions[phys_regions_count].start = first; -
kernel/arch/ppc32/src/mm/frame.c
r9957a97 r96cd5b4 81 81 } else { 82 82 conf = zone_external_conf_alloc(count); 83 if (conf != 0) 84 zone_create(pfn, count, conf, 85 ZONE_AVAILABLE | ZONE_HIGHMEM); 83 zone_create(pfn, count, conf, 84 ZONE_AVAILABLE | ZONE_HIGHMEM); 86 85 } 87 86 } -
kernel/arch/sparc64/src/mm/sun4u/frame.c
r9957a97 r96cd5b4 79 79 } else { 80 80 confdata = zone_external_conf_alloc(count); 81 if (confdata != 0) 82 zone_create(pfn, count, confdata, 83 ZONE_AVAILABLE | ZONE_HIGHMEM); 81 zone_create(pfn, count, confdata, 82 ZONE_AVAILABLE | ZONE_HIGHMEM); 84 83 } 85 84 } 85 86 86 } 87 87 -
kernel/arch/sparc64/src/mm/sun4v/frame.c
r9957a97 r96cd5b4 79 79 } else { 80 80 confdata = zone_external_conf_alloc(count); 81 if (confdata != 0) 82 zone_create(pfn, count, confdata, 83 ZONE_AVAILABLE | ZONE_HIGHMEM); 81 zone_create(pfn, count, confdata, 82 ZONE_AVAILABLE | ZONE_HIGHMEM); 84 83 } 85 84 } 85 86 86 } 87 87 -
kernel/generic/src/mm/frame.c
r9957a97 r96cd5b4 870 870 size_t order = ispwr2(size) ? fnzb(size) : (fnzb(size) + 1); 871 871 872 return ADDR2PFN((uintptr_t) frame_alloc(order - FRAME_WIDTH, 873 FRAME_LOWMEM | FRAME_ATOMIC)); 872 return ADDR2PFN((uintptr_t) frame_alloc(order - FRAME_WIDTH, FRAME_LOWMEM)); 874 873 } 875 874 -
uspace/app/websrv/websrv.c
r9957a97 r96cd5b4 46 46 #include <net/socket.h> 47 47 48 #include <arg_parse.h>49 #include <macros.h>50 48 #include <str.h> 51 #include <str_error.h> 52 53 #define NAME "websrv" 54 55 #define DEFAULT_PORT 8080 56 #define BACKLOG_SIZE 3 57 58 #define WEB_ROOT "/data/web" 49 50 #define PORT_NUMBER 8080 51 #define BACKLOG_SIZE 3 52 53 #define WEB_ROOT "/data/web" 59 54 60 55 /** Buffer for receiving the request. */ 61 #define BUFFER_SIZE 1024 62 63 static uint16_t port = DEFAULT_PORT; 64 56 #define BUFFER_SIZE 1024 65 57 static char rbuf[BUFFER_SIZE]; 66 static size_t rbuf_out; 67 static size_t rbuf_in; 58 static size_t rbuf_out, rbuf_in; 68 59 69 60 static char lbuf[BUFFER_SIZE + 1]; … … 72 63 static char fbuf[BUFFER_SIZE]; 73 64 74 /** Responses to send to client. */ 75 76 static const char *msg_ok = 65 /** Response to send to client. */ 66 static const char *ok_msg = 77 67 "HTTP/1.0 200 OK\r\n" 78 68 "\r\n"; 79 69 80 static const char *msg_bad_request =81 "HTTP/1.0 400 Bad Request\r\n"82 "\r\n"83 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"84 "<html><head>\r\n"85 "<title>400 Bad Request</title>\r\n"86 "</head>\r\n"87 "<body>\r\n"88 "<h1>Bad Request</h1>\r\n"89 "<p>The requested URL has bad syntax.</p>\r\n"90 "</body>\r\n"91 "</html>\r\n";92 93 static const char *msg_not_found =94 "HTTP/1.0 404 Not Found\r\n"95 "\r\n"96 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"97 "<html><head>\r\n"98 "<title>404 Not Found</title>\r\n"99 "</head>\r\n"100 "<body>\r\n"101 "<h1>Not Found</h1>\r\n"102 "<p>The requested URL was not found on this server.</p>\r\n"103 "</body>\r\n"104 "</html>\r\n";105 106 static const char *msg_not_implemented =107 "HTTP/1.0 501 Not Implemented\r\n"108 "\r\n"109 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"110 "<html><head>\r\n"111 "<title>501 Not Implemented</title>\r\n"112 "</head>\r\n"113 "<body>\r\n"114 "<h1>Not Implemented</h1>\r\n"115 "<p>The requested method is not implemented on this server.</p>\r\n"116 "</body>\r\n"117 "</html>\r\n";118 119 70 /** Receive one character (with buffering) */ 120 71 static int recv_char(int fd, char *c) 121 72 { 73 ssize_t rc; 74 122 75 if (rbuf_out == rbuf_in) { 123 76 rbuf_out = 0; 124 77 rbuf_in = 0; 125 126 ssize_trc = recv(fd, rbuf, BUFFER_SIZE, 0);78 79 rc = recv(fd, rbuf, BUFFER_SIZE, 0); 127 80 if (rc <= 0) { 128 fprintf(stderr,"recv() failed (%zd)\n", rc);81 printf("recv() failed (%zd)\n", rc); 129 82 return rc; 130 83 } 131 84 132 85 rbuf_in = rc; 133 86 } 134 87 135 88 *c = rbuf[rbuf_out++]; 136 89 return EOK; 137 90 } 138 91 139 /** Receive one line with length limit */92 /** Receive one line with length limit. */ 140 93 static int recv_line(int fd) 141 94 { 142 char *bp = lbuf; 143 char c = '\0'; 144 95 char c, prev; 96 int rc; 97 char *bp; 98 99 bp = lbuf; c = '\0'; 145 100 while (bp < lbuf + BUFFER_SIZE) { 146 char prev = c; 147 int rc = recv_char(fd, &c); 148 101 prev = c; 102 rc = recv_char(fd, &c); 149 103 if (rc != EOK) 150 104 return rc; 151 105 152 106 *bp++ = c; 153 if ( (prev == '\r') && (c == '\n'))107 if (prev == '\r' && c == '\n') 154 108 break; 155 109 } 156 110 157 111 lbuf_used = bp - lbuf; 158 112 *bp = '\0'; 159 113 160 114 if (bp == lbuf + BUFFER_SIZE) 161 115 return ELIMIT; 162 116 163 117 return EOK; 164 118 } … … 166 120 static bool uri_is_valid(char *uri) 167 121 { 122 char *cp; 123 char c; 124 168 125 if (uri[0] != '/') 169 126 return false; 170 171 127 if (uri[1] == '.') 172 128 return false; 173 174 char *cp = uri + 1; 175 129 130 cp = uri + 1; 176 131 while (*cp != '\0') { 177 c har c= *cp++;132 c = *cp++; 178 133 if (c == '/') 179 134 return false; 180 135 } 181 136 182 137 return true; 183 138 } … … 185 140 static int send_response(int conn_sd, const char *msg) 186 141 { 187 size_t response_size = str_size(msg); 188 189 fprintf(stderr, "Sending response\n"); 190 ssize_t rc = send(conn_sd, (void *) msg, response_size, 0); 142 size_t response_size; 143 ssize_t rc; 144 145 response_size = str_size(msg); 146 147 /* Send a canned response. */ 148 printf("Send response...\n"); 149 rc = send(conn_sd, (void *) msg, response_size, 0); 191 150 if (rc < 0) { 192 fprintf(stderr, "send() failed\n");151 printf("send() failed.\n"); 193 152 return rc; 194 153 } 195 154 196 155 return EOK; 197 156 } … … 199 158 static int uri_get(const char *uri, int conn_sd) 200 159 { 160 int rc; 161 char *fname; 162 int fd; 163 ssize_t nr; 164 201 165 if (str_cmp(uri, "/") == 0) 202 166 uri = "/index.htm"; 203 204 char *fname; 205 int rc = asprintf(&fname, "%s%s", WEB_ROOT, uri); 167 168 rc = asprintf(&fname, "%s%s", WEB_ROOT, uri); 206 169 if (rc < 0) 207 170 return ENOMEM; 208 209 intfd = open(fname, O_RDONLY);171 172 fd = open(fname, O_RDONLY); 210 173 if (fd < 0) { 211 rc = send_response(conn_sd, msg_not_found);174 printf("File '%s' not found.\n", fname); 212 175 free(fname); 213 return rc;214 } 215 176 return ENOENT; 177 } 178 216 179 free(fname); 217 218 rc = send_response(conn_sd, msg_ok);180 181 rc = send_response(conn_sd, ok_msg); 219 182 if (rc != EOK) 220 183 return rc; 221 184 222 185 while (true) { 223 ssize_tnr = read(fd, fbuf, BUFFER_SIZE);186 nr = read(fd, fbuf, BUFFER_SIZE); 224 187 if (nr == 0) 225 188 break; 226 189 227 190 if (nr < 0) { 228 191 close(fd); 229 192 return EIO; 230 193 } 231 194 232 195 rc = send(conn_sd, fbuf, nr, 0); 233 196 if (rc < 0) { 234 fprintf(stderr,"send() failed\n");197 printf("send() failed\n"); 235 198 close(fd); 236 199 return rc; 237 200 } 238 201 } 239 202 240 203 close(fd); 241 204 242 205 return EOK; 243 206 } … … 245 208 static int req_process(int conn_sd) 246 209 { 247 int rc = recv_line(conn_sd); 210 int rc; 211 char *uri, *end_uri; 212 213 rc = recv_line(conn_sd); 248 214 if (rc != EOK) { 249 fprintf(stderr,"recv_line() failed\n");215 printf("recv_line() failed\n"); 250 216 return rc; 251 217 } 252 253 fprintf(stderr, "Request:%s", lbuf);254 218 219 printf("%s", lbuf); 220 255 221 if (str_lcmp(lbuf, "GET ", 4) != 0) { 256 rc = send_response(conn_sd, msg_not_implemented);257 return rc;258 } 259 260 char *uri = lbuf + 4;261 char *end_uri = str_chr(uri, ' ');222 printf("Invalid HTTP method.\n"); 223 return EINVAL; 224 } 225 226 uri = lbuf + 4; 227 end_uri = str_chr(uri, ' '); 262 228 if (end_uri == NULL) { 263 229 end_uri = lbuf + lbuf_used - 2; 264 230 assert(*end_uri == '\r'); 265 231 } 266 232 267 233 *end_uri = '\0'; 268 fprintf(stderr, "Requested URI: %s\n", uri);269 234 printf("Requested URI '%s'.\n", uri); 235 270 236 if (!uri_is_valid(uri)) { 271 rc = send_response(conn_sd, msg_bad_request);272 return rc;273 } 274 237 printf("Invalid request URI.\n"); 238 return EINVAL; 239 } 240 275 241 return uri_get(uri, conn_sd); 276 242 } 277 243 278 static void usage(void) 279 { 280 printf("Skeletal server\n" 281 "\n" 282 "Usage: " NAME " [options]\n" 283 "\n" 284 "Where options are:\n" 285 "-p port_number | --port=port_number\n" 286 "\tListening port (default " STRING(DEFAULT_PORT) ").\n" 287 "\n" 288 "-h | --help\n" 289 "\tShow this application help.\n"); 290 } 291 292 static int parse_option(int argc, char *argv[], int *index) 293 { 294 int value; 244 int main(int argc, char *argv[]) 245 { 246 struct sockaddr_in addr; 247 struct sockaddr_in raddr; 248 249 socklen_t raddr_len; 250 251 int listen_sd, conn_sd; 295 252 int rc; 296 297 switch (argv[*index][1]) { 298 case 'h': 299 usage(); 300 exit(0); 301 break; 302 case 'p': 303 rc = arg_parse_int(argc, argv, index, &value, 0); 304 if (rc != EOK) 305 return rc; 306 307 port = (uint16_t) value; 308 break; 309 /* Long options with double dash */ 310 case '-': 311 if (str_lcmp(argv[*index] + 2, "help", 5) == 0) { 312 usage(); 313 exit(0); 314 } else if (str_lcmp(argv[*index] + 2, "port=", 5) == 0) { 315 rc = arg_parse_int(argc, argv, index, &value, 7); 316 if (rc != EOK) 317 return rc; 318 319 port = (uint16_t) value; 320 } else { 321 usage(); 322 return EINVAL; 323 } 324 break; 325 default: 326 usage(); 327 return EINVAL; 328 } 329 330 return EOK; 331 } 332 333 int main(int argc, char *argv[]) 334 { 335 /* Parse command line arguments */ 336 for (int i = 1; i < argc; i++) { 337 if (argv[i][0] == '-') { 338 int rc = parse_option(argc, argv, &i); 339 if (rc != EOK) 340 return rc; 341 } else { 342 usage(); 343 return EINVAL; 344 } 345 } 346 347 struct sockaddr_in addr; 348 253 254 349 255 addr.sin_family = AF_INET; 350 addr.sin_port = htons(port); 351 352 int rc = inet_pton(AF_INET, "127.0.0.1", (void *) 353 &addr.sin_addr.s_addr); 256 addr.sin_port = htons(PORT_NUMBER); 257 258 rc = inet_pton(AF_INET, "127.0.0.1", (void *) &addr.sin_addr.s_addr); 354 259 if (rc != EOK) { 355 fprintf(stderr, "Error parsing network address (%s)\n", 356 str_error(rc)); 260 printf("Error parsing network address.\n"); 357 261 return 1; 358 262 } 359 360 fprintf(stderr, "Creating socket\n");361 362 intlisten_sd = socket(PF_INET, SOCK_STREAM, 0);263 264 printf("Creating socket.\n"); 265 266 listen_sd = socket(PF_INET, SOCK_STREAM, 0); 363 267 if (listen_sd < 0) { 364 fprintf(stderr, "Error creating listening socket (%s)\n", 365 str_error(listen_sd)); 366 return 2; 367 } 368 268 printf("Error creating listening socket.\n"); 269 return 1; 270 } 271 369 272 rc = bind(listen_sd, (struct sockaddr *) &addr, sizeof(addr)); 370 273 if (rc != EOK) { 371 fprintf(stderr, "Error binding socket (%s)\n", 372 str_error(rc)); 373 return 3; 374 } 375 274 printf("Error binding socket.\n"); 275 return 1; 276 } 277 376 278 rc = listen(listen_sd, BACKLOG_SIZE); 377 279 if (rc != EOK) { 378 fprintf(stderr, "listen() failed (%s)\n", str_error(rc)); 379 return 4; 380 } 381 382 fprintf(stderr, "Listening for connections at port %" PRIu16 "\n", 383 port); 280 printf("Error calling listen() (%d).\n", rc); 281 return 1; 282 } 283 284 printf("Listening for connections at port number %u.\n", PORT_NUMBER); 384 285 while (true) { 385 struct sockaddr_in raddr; 386 socklen_t raddr_len = sizeof(raddr); 387 int conn_sd = accept(listen_sd, (struct sockaddr *) &raddr, 286 raddr_len = sizeof(raddr); 287 conn_sd = accept(listen_sd, (struct sockaddr *) &raddr, 388 288 &raddr_len); 389 289 390 290 if (conn_sd < 0) { 391 fprintf(stderr, "accept() failed (%s)\n", str_error(rc));291 printf("accept() failed.\n"); 392 292 continue; 393 293 } 394 395 fprintf(stderr, "Connection accepted (sd=%d), " 396 "waiting for request\n", conn_sd); 397 398 rbuf_out = 0; 399 rbuf_in = 0; 400 294 295 printf("Accepted connection, sd=%d.\n", conn_sd); 296 297 printf("Wait for client request\n"); 298 rbuf_out = rbuf_in = 0; 299 401 300 rc = req_process(conn_sd); 402 if (rc != EOK) 403 fprintf(stderr, "Error processing request (%s)\n", 404 str_error(rc)); 405 301 if (rc != EOK) 302 printf("Error processing request.\n"); 303 406 304 rc = closesocket(conn_sd); 407 305 if (rc != EOK) { 408 fprintf(stderr, "Error closing connection socket (%s)\n", 409 str_error(rc)); 306 printf("Error closing connection socket: %d\n", rc); 410 307 closesocket(listen_sd); 411 return 5;412 } 413 414 fprintf(stderr, "Connection closed\n");415 } 416 417 /* Not reached */308 return 1; 309 } 310 311 printf("Closed connection.\n"); 312 } 313 314 /* Not reached. */ 418 315 return 0; 419 316 } -
uspace/drv/nic/e1k/e1k.c
r9957a97 r96cd5b4 44 44 #include <libarch/ddi.h> 45 45 #include <as.h> 46 #include <ddf/log.h>47 46 #include <ddf/interrupt.h> 48 47 #include <devman.h> … … 112 111 /** E1000 device data */ 113 112 typedef struct { 114 /** Device configuration */115 e1000_info_t info;116 117 113 /** Physical registers base address */ 118 114 void *reg_base_phys; … … 147 143 /** Used milticast Receive addrress count */ 148 144 unsigned int multicast_ra_count; 145 146 /** PCI device ID */ 147 uint16_t device_id; 149 148 150 149 /** The irq assigned */ … … 1889 1888 /* Allocate driver data for the device. */ 1890 1889 e1000_t *e1000 = e1000_create_dev_data(dev); 1891 if (e1000 == NULL) { 1892 ddf_msg(LVL_ERROR, "Unable to allocate device softstate"); 1890 if (e1000 == NULL) 1893 1891 return ENOMEM; 1894 }1895 1892 1896 1893 /* Obtain and fill hardware resources info */ 1897 1894 int rc = e1000_get_resource_info(dev); 1898 1895 if (rc != EOK) { 1899 ddf_msg(LVL_ERROR, "Cannot obtain hardware resources");1900 1896 e1000_dev_cleanup(dev); 1901 1897 return rc; 1902 1898 } 1903 1899 1904 uint16_t device_id;1905 1900 rc = pci_config_space_read_16(dev->parent_sess, PCI_DEVICE_ID, 1906 & device_id);1901 &e1000->device_id); 1907 1902 if (rc != EOK) { 1908 ddf_msg(LVL_ERROR, "Cannot access PCI configuration space");1909 1903 e1000_dev_cleanup(dev); 1910 1904 return rc; 1911 }1912 1913 e1000_board_t board;1914 switch (device_id) {1915 case 0x100e:1916 case 0x1015:1917 case 0x1016:1918 case 0x1017:1919 board = E1000_82540;1920 break;1921 case 0x1013:1922 case 0x1018:1923 case 0x1078:1924 board = E1000_82541;1925 break;1926 case 0x1076:1927 case 0x1077:1928 case 0x107c:1929 board = E1000_82541REV2;1930 break;1931 case 0x100f:1932 case 0x1011:1933 case 0x1026:1934 case 0x1027:1935 case 0x1028:1936 board = E1000_82545;1937 break;1938 case 0x1010:1939 case 0x1012:1940 case 0x101d:1941 case 0x1079:1942 case 0x107a:1943 case 0x107b:1944 board = E1000_82546;1945 break;1946 case 0x1019:1947 case 0x101a:1948 board = E1000_82547;1949 break;1950 case 0x10b9:1951 board = E1000_82572;1952 break;1953 case 0x1096:1954 board = E1000_80003ES2;1955 break;1956 default:1957 ddf_msg(LVL_ERROR, "Device not supported (%#" PRIx16 ")",1958 device_id);1959 e1000_dev_cleanup(dev);1960 return ENOTSUP;1961 }1962 1963 switch (board) {1964 case E1000_82540:1965 case E1000_82541:1966 case E1000_82541REV2:1967 case E1000_82545:1968 case E1000_82546:1969 case E1000_82572:1970 e1000->info.eerd_start = 0x01;1971 e1000->info.eerd_done = 0x10;1972 e1000->info.eerd_address_offset = 8;1973 e1000->info.eerd_data_offset = 16;1974 break;1975 case E1000_82547:1976 case E1000_80003ES2:1977 e1000->info.eerd_start = 0x01;1978 e1000->info.eerd_done = 0x02;1979 e1000->info.eerd_address_offset = 2;1980 e1000->info.eerd_data_offset = 16;1981 break;1982 1905 } 1983 1906 … … 2100 2023 fibril_mutex_lock(&e1000->eeprom_lock); 2101 2024 2025 uint32_t eerd_done; 2026 uint32_t eerd_address_offset; 2027 2028 switch (e1000->device_id) { 2029 case 0x107c: 2030 case 0x1013: 2031 case 0x1018: 2032 case 0x1019: 2033 case 0x101A: 2034 case 0x1076: 2035 case 0x1077: 2036 case 0x1078: 2037 case 0x10b9: 2038 /* 82541xx and 82547GI/EI */ 2039 eerd_done = EERD_DONE_82541XX_82547GI_EI; 2040 eerd_address_offset = EERD_ADDRESS_OFFSET_82541XX_82547GI_EI; 2041 break; 2042 default: 2043 eerd_done = EERD_DONE; 2044 eerd_address_offset = EERD_ADDRESS_OFFSET; 2045 break; 2046 } 2047 2102 2048 /* Write address and START bit to EERD register */ 2103 uint32_t write_data = e1000->info.eerd_start | 2104 (((uint32_t) eeprom_address) << 2105 e1000->info.eerd_address_offset); 2049 uint32_t write_data = EERD_START | 2050 (((uint32_t) eeprom_address) << eerd_address_offset); 2106 2051 E1000_REG_WRITE(e1000, E1000_EERD, write_data); 2107 2052 2108 2053 uint32_t eerd = E1000_REG_READ(e1000, E1000_EERD); 2109 while ((eerd & e 1000->info.eerd_done) == 0) {2054 while ((eerd & eerd_done) == 0) { 2110 2055 usleep(1); 2111 2056 eerd = E1000_REG_READ(e1000, E1000_EERD); … … 2114 2059 fibril_mutex_unlock(&e1000->eeprom_lock); 2115 2060 2116 return (uint16_t) (eerd >> e1000->info.eerd_data_offset);2061 return (uint16_t) (eerd >> EERD_DATA_OFFSET); 2117 2062 } 2118 2063 … … 2283 2228 nic_driver_implement(&e1000_driver_ops, &e1000_dev_ops, 2284 2229 &e1000_nic_iface); 2285 2286 ddf_log_init(NAME, LVL_ERROR);2287 ddf_msg(LVL_NOTE, "HelenOS E1000 driver started");2288 2230 return ddf_driver_main(&e1000_driver); 2289 2231 } -
uspace/drv/nic/e1k/e1k.h
r9957a97 r96cd5b4 82 82 } e1000_tx_descriptor_t; 83 83 84 /** E1000 boards */85 typedef enum {86 E1000_82540,87 E1000_82541,88 E1000_82541REV2,89 E1000_82545,90 E1000_82546,91 E1000_82547,92 E1000_82572,93 E1000_80003ES294 } e1000_board_t;95 96 typedef struct {97 uint32_t eerd_start;98 uint32_t eerd_done;99 100 uint32_t eerd_address_offset;101 uint32_t eerd_data_offset;102 } e1000_info_t;103 104 84 /** VLAN tag bits */ 105 typedef enum{85 enum e1000_vlantag { 106 86 VLANTAG_CFI = (1 << 12), /**< Canonical Form Indicator */ 107 } e1000_vlantag_t;87 }; 108 88 109 89 /** Transmit descriptor COMMAND field bits */ 110 typedef enum{90 enum e1000_txdescriptor_command { 111 91 TXDESCRIPTOR_COMMAND_VLE = (1 << 6), /**< VLAN Packet Enable */ 112 92 TXDESCRIPTOR_COMMAND_RS = (1 << 3), /**< Report Status */ 113 93 TXDESCRIPTOR_COMMAND_IFCS = (1 << 1), /**< Insert FCS */ 114 94 TXDESCRIPTOR_COMMAND_EOP = (1 << 0) /**< End Of Packet */ 115 } e1000_txdescriptor_command_t;95 }; 116 96 117 97 /** Transmit descriptor STATUS field bits */ 118 typedef enum{98 enum e1000_txdescriptor_status { 119 99 TXDESCRIPTOR_STATUS_DD = (1 << 0) /**< Descriptor Done */ 120 } e1000_txdescriptor_status_t;100 }; 121 101 122 102 /** E1000 Registers */ 123 typedef enum{103 enum e1000_registers { 124 104 E1000_CTRL = 0x0, /**< Device Control Register */ 125 105 E1000_STATUS = 0x8, /**< Device Status Register */ … … 150 130 E1000_IMS = 0xD0, /**< Interrupt Mask Set/Read Register */ 151 131 E1000_IMC = 0xD8 /**< Interrupt Mask Clear Register */ 152 } e1000_registers_t; 132 }; 133 134 /** EEPROM Read Register fields */ 135 enum e1000_eerd { 136 /** Start Read */ 137 EERD_START = (1 << 0), 138 /** Read Done */ 139 EERD_DONE = (1 << 4), 140 /** Read Done for 82541xx and 82547GI/EI */ 141 EERD_DONE_82541XX_82547GI_EI = (1 << 1), 142 /** Read Address offset */ 143 EERD_ADDRESS_OFFSET = 8, 144 /** Read Address offset for 82541xx and 82547GI/EI */ 145 EERD_ADDRESS_OFFSET_82541XX_82547GI_EI = 2, 146 /** Read Data */ 147 EERD_DATA_OFFSET = 16 148 }; 153 149 154 150 /** Device Control Register fields */ 155 typedef enum{151 enum e1000_ctrl { 156 152 CTRL_FD = (1 << 0), /**< Full-Duplex */ 157 153 CTRL_LRST = (1 << 3), /**< Link Reset */ … … 180 176 CTRL_VME = (1 << 30), /**< VLAN Mode Enable */ 181 177 CTRL_PHY_RST = (1 << 31) /**< PHY Reset */ 182 } e1000_ctrl_t;178 }; 183 179 184 180 /** Device Status Register fields */ 185 typedef enum{181 enum e1000_status { 186 182 STATUS_FD = (1 << 0), /**< Link Full Duplex configuration Indication */ 187 183 STATUS_LU = (1 << 1), /**< Link Up Indication */ … … 201 197 /** Link speed setting 1000 Mb/s value variant B */ 202 198 STATUS_SPEED_1000B = 3, 203 } e1000_status_t;199 }; 204 200 205 201 /** Transmit IPG Register fields … … 208 204 * 209 205 */ 210 typedef enum{206 enum e1000_tipg { 211 207 TIPG_IPGT_SHIFT = 0, /**< IPG Transmit Time shift */ 212 208 TIPG_IPGR1_SHIFT = 10, /**< IPG Receive Time 1 */ 213 209 TIPG_IPGR2_SHIFT = 20 /**< IPG Receive Time 2 */ 214 } e1000_tipg_t;210 }; 215 211 216 212 /** Transmit Control Register fields */ 217 typedef enum{213 enum e1000_tctl { 218 214 TCTL_EN = (1 << 1), /**< Transmit Enable */ 219 215 TCTL_PSP = (1 << 3), /**< Pad Short Packets */ 220 216 TCTL_CT_SHIFT = 4, /**< Collision Threshold shift */ 221 217 TCTL_COLD_SHIFT = 12 /**< Collision Distance shift */ 222 } e1000_tctl_t;218 }; 223 219 224 220 /** ICR register fields */ 225 typedef enum{221 enum e1000_icr { 226 222 ICR_TXDW = (1 << 0), /**< Transmit Descriptor Written Back */ 227 223 ICR_RXT0 = (1 << 7) /**< Receiver Timer Interrupt */ 228 } e1000_icr_t;224 }; 229 225 230 226 /** RAH register fields */ 231 typedef enum{227 enum e1000_rah { 232 228 RAH_AV = (1 << 31) /**< Address Valid */ 233 } e1000_rah_t;229 }; 234 230 235 231 /** RCTL register fields */ 236 typedef enum{232 enum e1000_rctl { 237 233 RCTL_EN = (1 << 1), /**< Receiver Enable */ 238 234 RCTL_SBP = (1 << 2), /**< Store Bad Packets */ … … 241 237 RCTL_BAM = (1 << 15), /**< Broadcast Accept Mode */ 242 238 RCTL_VFE = (1 << 18) /**< VLAN Filter Enable */ 243 } e1000_rctl_t;239 }; 244 240 245 241 #endif -
uspace/drv/nic/e1k/e1k.ma
r9957a97 r96cd5b4 22 22 10 pci/ven=8086&dev=107b 23 23 10 pci/ven=8086&dev=107c 24 10 pci/ven=8086&dev=1096 24 10 pci/ven=8086&dev=1107 25 10 pci/ven=8086&dev=1112 25 26 10 pci/ven=8086&dev=10b9
Note:
See TracChangeset
for help on using the changeset viewer.