Changes in / [96cd5b4:9957a97] in mainline
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/mm/frame.c
r96cd5b4 r9957a97 60 60 } else { 61 61 pfn_t conf = zone_external_conf_alloc(SIZE2FRAMES(size)); 62 63 zone_create(ADDR2PFN(base), SIZE2FRAMES(size), conf,64 ZONE_AVAILABLE | ZONE_HIGHMEM);62 if (conf != 0) 63 zone_create(ADDR2PFN(base), SIZE2FRAMES(size), conf, 64 ZONE_AVAILABLE | ZONE_HIGHMEM); 65 65 } 66 66 -
kernel/arch/ia32/src/mm/frame.c
r96cd5b4 r9957a97 79 79 } else { 80 80 conf = zone_external_conf_alloc(count); 81 zone_create(pfn, count, conf, 82 ZONE_AVAILABLE | ZONE_HIGHMEM); 81 if (conf != 0) 82 zone_create(pfn, count, conf, 83 ZONE_AVAILABLE | ZONE_HIGHMEM); 83 84 } 84 85 } else if ((e820table[i].type == MEMMAP_MEMORY_ACPI) || -
kernel/arch/ia64/src/mm/frame.c
r96cd5b4 r9957a97 79 79 ZONE_AVAILABLE | ZONE_LOWMEM); 80 80 } else { 81 pfn_t conf; 82 83 conf = zone_external_conf_alloc(count); 84 zone_create(pfn, count, conf, 85 ZONE_AVAILABLE | ZONE_HIGHMEM); 81 pfn_t conf = zone_external_conf_alloc(count); 82 if (conf != 0) 83 zone_create(pfn, count, conf, 84 ZONE_AVAILABLE | ZONE_HIGHMEM); 86 85 } 87 86 } -
kernel/arch/mips32/src/mm/frame.c
r96cd5b4 r9957a97 156 156 } else { 157 157 conf_frame = zone_external_conf_alloc(count); 158 zone_create(first, count, conf_frame,159 ZONE_AVAILABLE | ZONE_HIGHMEM);160 }161 162 158 if (conf_frame != 0) 159 zone_create(first, count, conf_frame, 160 ZONE_AVAILABLE | ZONE_HIGHMEM); 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
r96cd5b4 r9957a97 148 148 } else { 149 149 conf_frame = zone_external_conf_alloc(count); 150 zone_create(first, count, conf_frame,151 ZONE_AVAILABLE | ZONE_HIGHMEM);152 }153 154 150 if (conf_frame != 0) 151 zone_create(first, count, conf_frame, 152 ZONE_AVAILABLE | ZONE_HIGHMEM); 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
r96cd5b4 r9957a97 81 81 } else { 82 82 conf = zone_external_conf_alloc(count); 83 zone_create(pfn, count, conf, 84 ZONE_AVAILABLE | ZONE_HIGHMEM); 83 if (conf != 0) 84 zone_create(pfn, count, conf, 85 ZONE_AVAILABLE | ZONE_HIGHMEM); 85 86 } 86 87 } -
kernel/arch/sparc64/src/mm/sun4u/frame.c
r96cd5b4 r9957a97 79 79 } else { 80 80 confdata = zone_external_conf_alloc(count); 81 zone_create(pfn, count, confdata, 82 ZONE_AVAILABLE | ZONE_HIGHMEM); 81 if (confdata != 0) 82 zone_create(pfn, count, confdata, 83 ZONE_AVAILABLE | ZONE_HIGHMEM); 83 84 } 84 85 } 85 86 86 } 87 87 -
kernel/arch/sparc64/src/mm/sun4v/frame.c
r96cd5b4 r9957a97 79 79 } else { 80 80 confdata = zone_external_conf_alloc(count); 81 zone_create(pfn, count, confdata, 82 ZONE_AVAILABLE | ZONE_HIGHMEM); 81 if (confdata != 0) 82 zone_create(pfn, count, confdata, 83 ZONE_AVAILABLE | ZONE_HIGHMEM); 83 84 } 84 85 } 85 86 86 } 87 87 -
kernel/generic/src/mm/frame.c
r96cd5b4 r9957a97 870 870 size_t order = ispwr2(size) ? fnzb(size) : (fnzb(size) + 1); 871 871 872 return ADDR2PFN((uintptr_t) frame_alloc(order - FRAME_WIDTH, FRAME_LOWMEM)); 872 return ADDR2PFN((uintptr_t) frame_alloc(order - FRAME_WIDTH, 873 FRAME_LOWMEM | FRAME_ATOMIC)); 873 874 } 874 875 -
uspace/app/websrv/websrv.c
r96cd5b4 r9957a97 46 46 #include <net/socket.h> 47 47 48 #include <arg_parse.h> 49 #include <macros.h> 48 50 #include <str.h> 49 50 #define PORT_NUMBER 8080 51 #define BACKLOG_SIZE 3 52 53 #define WEB_ROOT "/data/web" 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" 54 59 55 60 /** Buffer for receiving the request. */ 56 #define BUFFER_SIZE 1024 61 #define BUFFER_SIZE 1024 62 63 static uint16_t port = DEFAULT_PORT; 64 57 65 static char rbuf[BUFFER_SIZE]; 58 static size_t rbuf_out, rbuf_in; 66 static size_t rbuf_out; 67 static size_t rbuf_in; 59 68 60 69 static char lbuf[BUFFER_SIZE + 1]; … … 63 72 static char fbuf[BUFFER_SIZE]; 64 73 65 /** Response to send to client. */ 66 static const char *ok_msg = 74 /** Responses to send to client. */ 75 76 static const char *msg_ok = 67 77 "HTTP/1.0 200 OK\r\n" 68 78 "\r\n"; 69 79 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 70 119 /** Receive one character (with buffering) */ 71 120 static int recv_char(int fd, char *c) 72 121 { 73 ssize_t rc;74 75 122 if (rbuf_out == rbuf_in) { 76 123 rbuf_out = 0; 77 124 rbuf_in = 0; 78 79 rc = recv(fd, rbuf, BUFFER_SIZE, 0);125 126 ssize_t rc = recv(fd, rbuf, BUFFER_SIZE, 0); 80 127 if (rc <= 0) { 81 printf("recv() failed (%zd)\n", rc);128 fprintf(stderr, "recv() failed (%zd)\n", rc); 82 129 return rc; 83 130 } 84 131 85 132 rbuf_in = rc; 86 133 } 87 134 88 135 *c = rbuf[rbuf_out++]; 89 136 return EOK; 90 137 } 91 138 92 /** Receive one line with length limit .*/139 /** Receive one line with length limit */ 93 140 static int recv_line(int fd) 94 141 { 95 char c, prev; 96 int rc; 97 char *bp; 98 99 bp = lbuf; c = '\0'; 142 char *bp = lbuf; 143 char c = '\0'; 144 100 145 while (bp < lbuf + BUFFER_SIZE) { 101 prev = c; 102 rc = recv_char(fd, &c); 146 char prev = c; 147 int rc = recv_char(fd, &c); 148 103 149 if (rc != EOK) 104 150 return rc; 105 151 106 152 *bp++ = c; 107 if ( prev == '\r' && c == '\n')153 if ((prev == '\r') && (c == '\n')) 108 154 break; 109 155 } 110 156 111 157 lbuf_used = bp - lbuf; 112 158 *bp = '\0'; 113 159 114 160 if (bp == lbuf + BUFFER_SIZE) 115 161 return ELIMIT; 116 162 117 163 return EOK; 118 164 } … … 120 166 static bool uri_is_valid(char *uri) 121 167 { 122 char *cp;123 char c;124 125 168 if (uri[0] != '/') 126 169 return false; 170 127 171 if (uri[1] == '.') 128 172 return false; 129 130 cp = uri + 1; 173 174 char *cp = uri + 1; 175 131 176 while (*cp != '\0') { 132 c = *cp++;177 char c = *cp++; 133 178 if (c == '/') 134 179 return false; 135 180 } 136 181 137 182 return true; 138 183 } … … 140 185 static int send_response(int conn_sd, const char *msg) 141 186 { 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); 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); 150 191 if (rc < 0) { 151 printf("send() failed.\n");152 return rc; 153 } 154 192 fprintf(stderr, "send() failed\n"); 193 return rc; 194 } 195 155 196 return EOK; 156 197 } … … 158 199 static int uri_get(const char *uri, int conn_sd) 159 200 { 160 int rc;161 char *fname;162 int fd;163 ssize_t nr;164 165 201 if (str_cmp(uri, "/") == 0) 166 202 uri = "/index.htm"; 167 168 rc = asprintf(&fname, "%s%s", WEB_ROOT, uri); 203 204 char *fname; 205 int rc = asprintf(&fname, "%s%s", WEB_ROOT, uri); 169 206 if (rc < 0) 170 207 return ENOMEM; 171 172 fd = open(fname, O_RDONLY);208 209 int fd = open(fname, O_RDONLY); 173 210 if (fd < 0) { 174 printf("File '%s' not found.\n", fname);211 rc = send_response(conn_sd, msg_not_found); 175 212 free(fname); 176 return ENOENT;177 } 178 213 return rc; 214 } 215 179 216 free(fname); 180 181 rc = send_response(conn_sd, ok_msg);217 218 rc = send_response(conn_sd, msg_ok); 182 219 if (rc != EOK) 183 220 return rc; 184 221 185 222 while (true) { 186 nr = read(fd, fbuf, BUFFER_SIZE);223 ssize_t nr = read(fd, fbuf, BUFFER_SIZE); 187 224 if (nr == 0) 188 225 break; 189 226 190 227 if (nr < 0) { 191 228 close(fd); 192 229 return EIO; 193 230 } 194 231 195 232 rc = send(conn_sd, fbuf, nr, 0); 196 233 if (rc < 0) { 197 printf("send() failed\n");234 fprintf(stderr, "send() failed\n"); 198 235 close(fd); 199 236 return rc; 200 237 } 201 238 } 202 239 203 240 close(fd); 204 241 205 242 return EOK; 206 243 } … … 208 245 static int req_process(int conn_sd) 209 246 { 210 int rc; 211 char *uri, *end_uri; 212 213 rc = recv_line(conn_sd); 247 int rc = recv_line(conn_sd); 214 248 if (rc != EOK) { 215 printf("recv_line() failed\n");216 return rc; 217 } 218 219 printf("%s", lbuf);220 249 fprintf(stderr, "recv_line() failed\n"); 250 return rc; 251 } 252 253 fprintf(stderr, "Request: %s", lbuf); 254 221 255 if (str_lcmp(lbuf, "GET ", 4) != 0) { 222 printf("Invalid HTTP method.\n");223 return EINVAL;224 } 225 226 uri = lbuf + 4;227 end_uri = str_chr(uri, ' ');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, ' '); 228 262 if (end_uri == NULL) { 229 263 end_uri = lbuf + lbuf_used - 2; 230 264 assert(*end_uri == '\r'); 231 265 } 232 266 233 267 *end_uri = '\0'; 234 printf("Requested URI '%s'.\n", uri);235 268 fprintf(stderr, "Requested URI: %s\n", uri); 269 236 270 if (!uri_is_valid(uri)) { 237 printf("Invalid request URI.\n"); 271 rc = send_response(conn_sd, msg_bad_request); 272 return rc; 273 } 274 275 return uri_get(uri, conn_sd); 276 } 277 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; 295 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(); 238 327 return EINVAL; 239 328 } 240 241 return uri_get(uri, conn_sd);329 330 return EOK; 242 331 } 243 332 244 333 int main(int argc, char *argv[]) 245 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 246 347 struct sockaddr_in addr; 247 struct sockaddr_in raddr; 248 249 socklen_t raddr_len; 250 251 int listen_sd, conn_sd; 252 int rc; 253 254 348 255 349 addr.sin_family = AF_INET; 256 addr.sin_port = htons(PORT_NUMBER); 257 258 rc = inet_pton(AF_INET, "127.0.0.1", (void *) &addr.sin_addr.s_addr); 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); 259 354 if (rc != EOK) { 260 printf("Error parsing network address.\n"); 355 fprintf(stderr, "Error parsing network address (%s)\n", 356 str_error(rc)); 261 357 return 1; 262 358 } 263 264 printf("Creating socket.\n");265 266 listen_sd = socket(PF_INET, SOCK_STREAM, 0);359 360 fprintf(stderr, "Creating socket\n"); 361 362 int listen_sd = socket(PF_INET, SOCK_STREAM, 0); 267 363 if (listen_sd < 0) { 268 printf("Error creating listening socket.\n"); 269 return 1; 270 } 271 364 fprintf(stderr, "Error creating listening socket (%s)\n", 365 str_error(listen_sd)); 366 return 2; 367 } 368 272 369 rc = bind(listen_sd, (struct sockaddr *) &addr, sizeof(addr)); 273 370 if (rc != EOK) { 274 printf("Error binding socket.\n"); 275 return 1; 276 } 277 371 fprintf(stderr, "Error binding socket (%s)\n", 372 str_error(rc)); 373 return 3; 374 } 375 278 376 rc = listen(listen_sd, BACKLOG_SIZE); 279 377 if (rc != EOK) { 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); 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); 285 384 while (true) { 286 raddr_len = sizeof(raddr); 287 conn_sd = accept(listen_sd, (struct sockaddr *) &raddr, 385 struct sockaddr_in raddr; 386 socklen_t raddr_len = sizeof(raddr); 387 int conn_sd = accept(listen_sd, (struct sockaddr *) &raddr, 288 388 &raddr_len); 289 389 290 390 if (conn_sd < 0) { 291 printf("accept() failed.\n");391 fprintf(stderr, "accept() failed (%s)\n", str_error(rc)); 292 392 continue; 293 393 } 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 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 300 401 rc = req_process(conn_sd); 301 if (rc != EOK) 302 printf("Error processing request.\n"); 303 402 if (rc != EOK) 403 fprintf(stderr, "Error processing request (%s)\n", 404 str_error(rc)); 405 304 406 rc = closesocket(conn_sd); 305 407 if (rc != EOK) { 306 printf("Error closing connection socket: %d\n", rc); 408 fprintf(stderr, "Error closing connection socket (%s)\n", 409 str_error(rc)); 307 410 closesocket(listen_sd); 308 return 1;309 } 310 311 printf("Closed connection.\n");312 } 313 314 /* Not reached .*/411 return 5; 412 } 413 414 fprintf(stderr, "Connection closed\n"); 415 } 416 417 /* Not reached */ 315 418 return 0; 316 419 } -
uspace/drv/nic/e1k/e1k.c
r96cd5b4 r9957a97 44 44 #include <libarch/ddi.h> 45 45 #include <as.h> 46 #include <ddf/log.h> 46 47 #include <ddf/interrupt.h> 47 48 #include <devman.h> … … 111 112 /** E1000 device data */ 112 113 typedef struct { 114 /** Device configuration */ 115 e1000_info_t info; 116 113 117 /** Physical registers base address */ 114 118 void *reg_base_phys; … … 143 147 /** Used milticast Receive addrress count */ 144 148 unsigned int multicast_ra_count; 145 146 /** PCI device ID */147 uint16_t device_id;148 149 149 150 /** The irq assigned */ … … 1888 1889 /* Allocate driver data for the device. */ 1889 1890 e1000_t *e1000 = e1000_create_dev_data(dev); 1890 if (e1000 == NULL) 1891 if (e1000 == NULL) { 1892 ddf_msg(LVL_ERROR, "Unable to allocate device softstate"); 1891 1893 return ENOMEM; 1894 } 1892 1895 1893 1896 /* Obtain and fill hardware resources info */ 1894 1897 int rc = e1000_get_resource_info(dev); 1895 1898 if (rc != EOK) { 1899 ddf_msg(LVL_ERROR, "Cannot obtain hardware resources"); 1896 1900 e1000_dev_cleanup(dev); 1897 1901 return rc; 1898 1902 } 1899 1903 1904 uint16_t device_id; 1900 1905 rc = pci_config_space_read_16(dev->parent_sess, PCI_DEVICE_ID, 1901 & e1000->device_id);1906 &device_id); 1902 1907 if (rc != EOK) { 1908 ddf_msg(LVL_ERROR, "Cannot access PCI configuration space"); 1903 1909 e1000_dev_cleanup(dev); 1904 1910 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; 1905 1982 } 1906 1983 … … 2023 2100 fibril_mutex_lock(&e1000->eeprom_lock); 2024 2101 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 2048 2102 /* Write address and START bit to EERD register */ 2049 uint32_t write_data = EERD_START | 2050 (((uint32_t) eeprom_address) << eerd_address_offset); 2103 uint32_t write_data = e1000->info.eerd_start | 2104 (((uint32_t) eeprom_address) << 2105 e1000->info.eerd_address_offset); 2051 2106 E1000_REG_WRITE(e1000, E1000_EERD, write_data); 2052 2107 2053 2108 uint32_t eerd = E1000_REG_READ(e1000, E1000_EERD); 2054 while ((eerd & e erd_done) == 0) {2109 while ((eerd & e1000->info.eerd_done) == 0) { 2055 2110 usleep(1); 2056 2111 eerd = E1000_REG_READ(e1000, E1000_EERD); … … 2059 2114 fibril_mutex_unlock(&e1000->eeprom_lock); 2060 2115 2061 return (uint16_t) (eerd >> EERD_DATA_OFFSET);2116 return (uint16_t) (eerd >> e1000->info.eerd_data_offset); 2062 2117 } 2063 2118 … … 2228 2283 nic_driver_implement(&e1000_driver_ops, &e1000_dev_ops, 2229 2284 &e1000_nic_iface); 2285 2286 ddf_log_init(NAME, LVL_ERROR); 2287 ddf_msg(LVL_NOTE, "HelenOS E1000 driver started"); 2230 2288 return ddf_driver_main(&e1000_driver); 2231 2289 } -
uspace/drv/nic/e1k/e1k.h
r96cd5b4 r9957a97 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_80003ES2 94 } 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 84 104 /** VLAN tag bits */ 85 enum e1000_vlantag{105 typedef enum { 86 106 VLANTAG_CFI = (1 << 12), /**< Canonical Form Indicator */ 87 } ;107 } e1000_vlantag_t; 88 108 89 109 /** Transmit descriptor COMMAND field bits */ 90 enum e1000_txdescriptor_command{110 typedef enum { 91 111 TXDESCRIPTOR_COMMAND_VLE = (1 << 6), /**< VLAN Packet Enable */ 92 112 TXDESCRIPTOR_COMMAND_RS = (1 << 3), /**< Report Status */ 93 113 TXDESCRIPTOR_COMMAND_IFCS = (1 << 1), /**< Insert FCS */ 94 114 TXDESCRIPTOR_COMMAND_EOP = (1 << 0) /**< End Of Packet */ 95 } ;115 } e1000_txdescriptor_command_t; 96 116 97 117 /** Transmit descriptor STATUS field bits */ 98 enum e1000_txdescriptor_status{118 typedef enum { 99 119 TXDESCRIPTOR_STATUS_DD = (1 << 0) /**< Descriptor Done */ 100 } ;120 } e1000_txdescriptor_status_t; 101 121 102 122 /** E1000 Registers */ 103 enum e1000_registers{123 typedef enum { 104 124 E1000_CTRL = 0x0, /**< Device Control Register */ 105 125 E1000_STATUS = 0x8, /**< Device Status Register */ … … 130 150 E1000_IMS = 0xD0, /**< Interrupt Mask Set/Read Register */ 131 151 E1000_IMC = 0xD8 /**< Interrupt Mask Clear Register */ 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 }; 152 } e1000_registers_t; 149 153 150 154 /** Device Control Register fields */ 151 enum e1000_ctrl{155 typedef enum { 152 156 CTRL_FD = (1 << 0), /**< Full-Duplex */ 153 157 CTRL_LRST = (1 << 3), /**< Link Reset */ … … 176 180 CTRL_VME = (1 << 30), /**< VLAN Mode Enable */ 177 181 CTRL_PHY_RST = (1 << 31) /**< PHY Reset */ 178 } ;182 } e1000_ctrl_t; 179 183 180 184 /** Device Status Register fields */ 181 enum e1000_status{185 typedef enum { 182 186 STATUS_FD = (1 << 0), /**< Link Full Duplex configuration Indication */ 183 187 STATUS_LU = (1 << 1), /**< Link Up Indication */ … … 197 201 /** Link speed setting 1000 Mb/s value variant B */ 198 202 STATUS_SPEED_1000B = 3, 199 } ;203 } e1000_status_t; 200 204 201 205 /** Transmit IPG Register fields … … 204 208 * 205 209 */ 206 enum e1000_tipg{210 typedef enum { 207 211 TIPG_IPGT_SHIFT = 0, /**< IPG Transmit Time shift */ 208 212 TIPG_IPGR1_SHIFT = 10, /**< IPG Receive Time 1 */ 209 213 TIPG_IPGR2_SHIFT = 20 /**< IPG Receive Time 2 */ 210 } ;214 } e1000_tipg_t; 211 215 212 216 /** Transmit Control Register fields */ 213 enum e1000_tctl{217 typedef enum { 214 218 TCTL_EN = (1 << 1), /**< Transmit Enable */ 215 219 TCTL_PSP = (1 << 3), /**< Pad Short Packets */ 216 220 TCTL_CT_SHIFT = 4, /**< Collision Threshold shift */ 217 221 TCTL_COLD_SHIFT = 12 /**< Collision Distance shift */ 218 } ;222 } e1000_tctl_t; 219 223 220 224 /** ICR register fields */ 221 enum e1000_icr{225 typedef enum { 222 226 ICR_TXDW = (1 << 0), /**< Transmit Descriptor Written Back */ 223 227 ICR_RXT0 = (1 << 7) /**< Receiver Timer Interrupt */ 224 } ;228 } e1000_icr_t; 225 229 226 230 /** RAH register fields */ 227 enum e1000_rah{231 typedef enum { 228 232 RAH_AV = (1 << 31) /**< Address Valid */ 229 } ;233 } e1000_rah_t; 230 234 231 235 /** RCTL register fields */ 232 enum e1000_rctl{236 typedef enum { 233 237 RCTL_EN = (1 << 1), /**< Receiver Enable */ 234 238 RCTL_SBP = (1 << 2), /**< Store Bad Packets */ … … 237 241 RCTL_BAM = (1 << 15), /**< Broadcast Accept Mode */ 238 242 RCTL_VFE = (1 << 18) /**< VLAN Filter Enable */ 239 } ;243 } e1000_rctl_t; 240 244 241 245 #endif -
uspace/drv/nic/e1k/e1k.ma
r96cd5b4 r9957a97 22 22 10 pci/ven=8086&dev=107b 23 23 10 pci/ven=8086&dev=107c 24 10 pci/ven=8086&dev=1107 25 10 pci/ven=8086&dev=1112 24 10 pci/ven=8086&dev=1096 26 25 10 pci/ven=8086&dev=10b9
Note:
See TracChangeset
for help on using the changeset viewer.