2 * Copyright (c) 2006 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $DragonFly: src/sys/platform/vkernel/platform/init.c,v 1.32 2007/03/16 13:41:40 swildner Exp $
37 #include <sys/types.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
43 #include <sys/random.h>
44 #include <sys/vkernel.h>
46 #include <sys/reboot.h>
48 #include <sys/msgbuf.h>
49 #include <sys/vmspace.h>
50 #include <sys/socket.h>
51 #include <sys/sockio.h>
52 #include <vm/vm_page.h>
54 #include <machine/globaldata.h>
55 #include <machine/tls.h>
56 #include <machine/md_var.h>
57 #include <machine/vmparam.h>
60 #include <net/if_arp.h>
61 #include <net/ethernet.h>
62 #include <net/bridge/if_bridgevar.h>
63 #include <netinet/in.h>
64 #include <arpa/inet.h>
75 vm_paddr_t phys_avail[16];
77 vm_paddr_t Maxmem_bytes;
79 struct vkdisk_info DiskInfo[VKDISK_MAX];
81 struct vknetif_info NetifInfo[VKNETIF_MAX];
86 vm_offset_t virtual_start;
87 vm_offset_t virtual_end;
88 vm_offset_t kernel_vm_end;
89 vm_offset_t crashdumpmap;
90 vm_offset_t clean_sva;
91 vm_offset_t clean_eva;
92 struct msgbuf *msgbufp;
95 vpte_t *KernelPTA; /* Warning: Offset for direct VA translation */
96 u_int cpu_feature; /* XXX */
97 u_int tsc_present; /* XXX */
99 struct privatespace *CPU_prvspace;
101 static struct trapframe proc0_tf;
102 static void *proc0paddr;
104 static void init_sys_memory(char *imageFile);
105 static void init_kern_memory(void);
106 static void init_globaldata(void);
107 static void init_vkernel(void);
108 static void init_disk(char *diskExp[], int diskFileNum);
109 static void init_netif(char *netifExp[], int netifFileNum);
110 static void usage(const char *ctl);
113 * Kernel startup for virtual kernels - standard main()
116 main(int ac, char **av)
118 char *memImageFile = NULL;
119 char *netifFile[VKNETIF_MAX];
120 char *diskFile[VKDISK_MAX];
122 int netifFileNum = 0;
131 kernel_mem_readonly = 1;
133 while ((c = getopt(ac, av, "svm:r:e:i:I:U")) != -1) {
137 * name=value:name=value:name=value...
140 kern_envp = malloc(n + 2);
141 for (i = 0; i < n; ++i) {
142 if (optarg[i] == ':')
145 kern_envp[i] = optarg[i];
151 boothowto |= RB_SINGLE;
157 memImageFile = optarg;
160 if (netifFileNum < VKNETIF_MAX)
161 netifFile[netifFileNum++] = optarg;
164 if (diskFileNum < VKDISK_MAX)
165 diskFile[diskFileNum++] = optarg;
168 Maxmem_bytes = strtoull(optarg, &suffix, 0);
185 usage("Bad maxmem option");
192 kernel_mem_readonly = 0;
198 init_sys_memory(memImageFile);
203 init_disk(diskFile, diskFileNum);
204 init_netif(netifFile, netifFileNum);
212 * Initialize system memory. This is the virtual kernel's 'RAM'.
216 init_sys_memory(char *imageFile)
223 * Figure out the system memory image size. If an image file was
224 * specified and -m was not specified, use the image file's size.
227 if (imageFile && stat(imageFile, &st) == 0 && Maxmem_bytes == 0)
228 Maxmem_bytes = (vm_paddr_t)st.st_size;
229 if ((imageFile == NULL || stat(imageFile, &st) < 0) &&
231 err(1, "Cannot create new memory file %s unless "
232 "system memory size is specified with -m",
238 * Maxmem must be known at this time
240 if (Maxmem_bytes < 32 * 1024 * 1024 || (Maxmem_bytes & SEG_MASK)) {
241 err(1, "Bad maxmem specification: 32MB minimum, "
242 "multiples of %dMB only",
243 SEG_SIZE / 1024 / 1024);
248 * Generate an image file name if necessary, then open/create the
249 * file exclusively locked. Do not allow multiple virtual kernels
250 * to use the same image file.
252 if (imageFile == NULL) {
253 for (i = 0; i < 1000000; ++i) {
254 asprintf(&imageFile, "/var/vkernel/memimg.%06d", i);
256 O_RDWR|O_CREAT|O_EXLOCK|O_NONBLOCK, 0644);
257 if (fd < 0 && errno == EWOULDBLOCK) {
264 fd = open(imageFile, O_RDWR|O_CREAT|O_EXLOCK|O_NONBLOCK, 0644);
266 printf("Using memory file: %s\n", imageFile);
267 if (fd < 0 || fstat(fd, &st) < 0) {
268 err(1, "Unable to open/create %s", imageFile);
273 * Truncate or extend the file as necessary.
275 if (st.st_size > Maxmem_bytes) {
276 ftruncate(fd, Maxmem_bytes);
277 } else if (st.st_size < Maxmem_bytes) {
279 off_t off = st.st_size & ~SEG_MASK;
281 kprintf("%s: Reserving blocks for memory image\n", imageFile);
282 zmem = malloc(SEG_SIZE);
283 bzero(zmem, SEG_SIZE);
284 lseek(fd, off, SEEK_SET);
285 while (off < Maxmem_bytes) {
286 if (write(fd, zmem, SEG_SIZE) != SEG_SIZE) {
287 err(1, "Unable to reserve blocks for memory image");
293 err(1, "Unable to reserve blocks for memory image");
297 Maxmem = Maxmem_bytes >> PAGE_SHIFT;
301 * Initialize kernel memory. This reserves kernel virtual memory by using
306 init_kern_memory(void)
314 * Memory map our kernel virtual memory space. Note that the
315 * kernel image itself is not made part of this memory for the
318 * The memory map must be segment-aligned so we can properly
321 base = mmap((void *)0x40000000, KERNEL_KVA_SIZE, PROT_READ|PROT_WRITE,
322 MAP_FILE|MAP_SHARED|MAP_VPAGETABLE, MemImageFd, 0);
323 if (base == MAP_FAILED) {
324 err(1, "Unable to mmap() kernel virtual memory!");
327 madvise(base, KERNEL_KVA_SIZE, MADV_NOSYNC);
328 KvaStart = (vm_offset_t)base;
329 KvaSize = KERNEL_KVA_SIZE;
330 KvaEnd = KvaStart + KvaSize;
333 * Create a top-level page table self-mapping itself.
335 * Initialize the page directory at physical page index 0 to point
336 * to an array of page table pages starting at physical page index 1
338 lseek(MemImageFd, 0L, 0);
339 for (i = 0; i < KERNEL_KVA_SIZE / SEG_SIZE; ++i) {
340 pte = ((i + 1) * PAGE_SIZE) | VPTE_V | VPTE_R | VPTE_W;
341 write(MemImageFd, &pte, sizeof(pte));
345 * Initialize the PTEs in the page table pages required to map the
346 * page table itself. This includes mapping the page directory page
347 * at the base so we go one more loop then normal.
349 lseek(MemImageFd, PAGE_SIZE, 0);
350 for (i = 0; i <= KERNEL_KVA_SIZE / SEG_SIZE * sizeof(vpte_t); ++i) {
351 pte = (i * PAGE_SIZE) | VPTE_V | VPTE_R | VPTE_W;
352 write(MemImageFd, &pte, sizeof(pte));
356 * Initialize remaining PTEs to 0. We may be reusing a memory image
357 * file. This is approximately a megabyte.
359 i = (KERNEL_KVA_SIZE / PAGE_SIZE - i) * sizeof(pte);
360 zero = malloc(PAGE_SIZE);
361 bzero(zero, PAGE_SIZE);
363 write(MemImageFd, zero, (i > PAGE_SIZE) ? PAGE_SIZE : i);
364 i = i - ((i > PAGE_SIZE) ? PAGE_SIZE : i);
369 * Enable the page table and calculate pointers to our self-map
370 * for easy kernel page table manipulation.
372 * KernelPTA must be offset so we can do direct VA translations
374 mcontrol(base, KERNEL_KVA_SIZE, MADV_SETMAP,
375 0 | VPTE_R | VPTE_W | VPTE_V);
376 KernelPTD = (vpte_t *)base; /* pg directory */
377 KernelPTA = (vpte_t *)((char *)base + PAGE_SIZE); /* pg table pages */
378 KernelPTA -= KvaStart >> PAGE_SHIFT;
381 * phys_avail[] represents unallocated physical memory. MI code
382 * will use phys_avail[] to create the vm_page array.
384 phys_avail[0] = PAGE_SIZE +
385 KERNEL_KVA_SIZE / PAGE_SIZE * sizeof(vpte_t);
386 phys_avail[0] = (phys_avail[0] + PAGE_MASK) & ~(vm_paddr_t)PAGE_MASK;
387 phys_avail[1] = Maxmem_bytes;
390 * (virtual_start, virtual_end) represent unallocated kernel virtual
391 * memory. MI code will create kernel_map using these parameters.
393 virtual_start = KvaStart + PAGE_SIZE +
394 KERNEL_KVA_SIZE / PAGE_SIZE * sizeof(vpte_t);
395 virtual_start = (virtual_start + PAGE_MASK) & ~(vm_offset_t)PAGE_MASK;
396 virtual_end = KvaStart + KERNEL_KVA_SIZE;
399 * kernel_vm_end could be set to virtual_end but we want some
400 * indication of how much of the kernel_map we've used, so
401 * set it low and let pmap_growkernel increase it even though we
402 * don't need to create any new page table pages.
404 kernel_vm_end = virtual_start;
407 * Allocate space for process 0's UAREA.
409 proc0paddr = (void *)virtual_start;
410 for (i = 0; i < UPAGES; ++i) {
411 pmap_kenter_quick(virtual_start, phys_avail[0]);
412 virtual_start += PAGE_SIZE;
413 phys_avail[0] += PAGE_SIZE;
419 crashdumpmap = virtual_start;
420 virtual_start += MAXDUMPPGS * PAGE_SIZE;
423 * msgbufp maps the system message buffer
425 assert((MSGBUF_SIZE & PAGE_MASK) == 0);
426 msgbufp = (void *)virtual_start;
427 for (i = 0; i < (MSGBUF_SIZE >> PAGE_SHIFT); ++i) {
428 pmap_kenter_quick(virtual_start, phys_avail[0]);
429 virtual_start += PAGE_SIZE;
430 phys_avail[0] += PAGE_SIZE;
432 msgbufinit(msgbufp, MSGBUF_SIZE);
435 * used by kern_memio for /dev/mem access
437 ptvmmap = (caddr_t)virtual_start;
438 virtual_start += PAGE_SIZE;
441 * Bootstrap the kernel_pmap
447 * Map the per-cpu globaldata for cpu #0. Allocate the space using
448 * virtual_start and phys_avail[0]
452 init_globaldata(void)
459 * Reserve enough KVA to cover possible cpus. This is a considerable
460 * amount of KVA since the privatespace structure includes two
461 * whole page table mappings.
463 virtual_start = (virtual_start + SEG_MASK) & ~(vm_offset_t)SEG_MASK;
464 CPU_prvspace = (void *)virtual_start;
465 virtual_start += sizeof(struct privatespace) * SMP_MAXCPU;
468 * Allocate enough physical memory to cover the mdglobaldata
469 * portion of the space and the idle stack and map the pages
470 * into KVA. For cpu #0 only.
472 for (i = 0; i < sizeof(struct mdglobaldata); i += PAGE_SIZE) {
474 va = (vm_offset_t)&CPU_prvspace[0].mdglobaldata + i;
475 pmap_kenter_quick(va, pa);
476 phys_avail[0] += PAGE_SIZE;
478 for (i = 0; i < sizeof(CPU_prvspace[0].idlestack); i += PAGE_SIZE) {
480 va = (vm_offset_t)&CPU_prvspace[0].idlestack + i;
481 pmap_kenter_quick(va, pa);
482 phys_avail[0] += PAGE_SIZE;
486 * Setup the %gs for cpu #0. The mycpu macro works after this
489 tls_set_fs(&CPU_prvspace[0], sizeof(struct privatespace));
493 * Initialize very low level systems including thread0, proc0, etc.
499 struct mdglobaldata *gd;
501 gd = &CPU_prvspace[0].mdglobaldata;
502 bzero(gd, sizeof(*gd));
504 gd->mi.gd_curthread = &thread0;
505 thread0.td_gd = &gd->mi;
509 gd->mi.gd_prvspace = &CPU_prvspace[0];
510 mi_gdinit(&gd->mi, 0);
512 mi_proc0init(&gd->mi, proc0paddr);
513 lwp0.lwp_md.md_regs = &proc0_tf;
518 #if 0 /* #ifdef DDB */
520 if (boothowto & RB_KDB)
521 Debugger("Boot flags requested debugger");
524 initializecpu(); /* Initialize CPU registers */
526 init_param2((phys_avail[1] - phys_avail[0]) / PAGE_SIZE);
530 * Map the message buffer
532 for (off = 0; off < round_page(MSGBUF_SIZE); off += PAGE_SIZE)
533 pmap_kenter((vm_offset_t)msgbufp + off, avail_end + off);
534 msgbufinit(msgbufp, MSGBUF_SIZE);
537 thread0.td_pcb_cr3 ... MMU
538 lwp0.lwp_md.md_regs = &proc0_tf;
543 * Filesystem image paths for the virtual kernel are optional.
544 * If specified they each should point to a disk image,
545 * the first of which will become the root disk.
547 * The virtual kernel caches data from our 'disk' just like a normal kernel,
548 * so we do not really want the real kernel to cache the data too. Use
549 * O_DIRECT to remove the duplication.
553 init_disk(char *diskExp[], int diskFileNum)
557 if (diskFileNum == 0)
560 for(i=0; i < diskFileNum; i++){
565 warnx("Invalid argument to '-r'");
569 if (DiskNum < VKDISK_MAX) {
571 struct vkdisk_info* info = NULL;
575 fd = open(fname, O_RDWR|O_DIRECT, 0644);
576 if (fd < 0 || fstat(fd, &st) < 0) {
577 err(1, "Unable to open/create %s", fname);
581 info = &DiskInfo[DiskNum];
586 memcpy(info->fname, fname, l);
589 rootdevnames[0] = "ufs:vkd0a";
593 warnx("vkd%d (%s) > VKD_MAX", DiskNum, fname);
601 netif_set_tapflags(int tap_unit, int f, int s)
606 bzero(&ifr, sizeof(ifr));
608 snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "tap%d", tap_unit);
609 if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {
610 warn("tap%d: ioctl(SIOCGIFFLAGS) failed", tap_unit);
617 * If the flags are already set/cleared, then we return
618 * immediately to avoid extra syscalls
620 flags = (ifr.ifr_flags & 0xffff) | (ifr.ifr_flagshigh << 16);
624 if ((flags & f) == 0)
635 * Fix up ifreq.ifr_name, since it may be trashed
636 * in previous ioctl(SIOCGIFFLAGS)
638 snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "tap%d", tap_unit);
640 ifr.ifr_flags = flags & 0xffff;
641 ifr.ifr_flagshigh = flags >> 16;
642 if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0) {
643 warn("tap%d: ioctl(SIOCSIFFLAGS) failed", tap_unit);
651 netif_set_tapaddr(int tap_unit, in_addr_t addr, in_addr_t mask, int s)
653 struct ifaliasreq ifra;
654 struct sockaddr_in *in;
656 bzero(&ifra, sizeof(ifra));
657 snprintf(ifra.ifra_name, sizeof(ifra.ifra_name), "tap%d", tap_unit);
660 in = (struct sockaddr_in *)&ifra.ifra_addr;
661 in->sin_family = AF_INET;
662 in->sin_len = sizeof(*in);
663 in->sin_addr.s_addr = addr;
667 in = (struct sockaddr_in *)&ifra.ifra_mask;
668 in->sin_len = sizeof(*in);
669 in->sin_addr.s_addr = mask;
672 if (ioctl(s, SIOCAIFADDR, &ifra) < 0) {
673 warn("tap%d: ioctl(SIOCAIFADDR) failed", tap_unit);
681 netif_add_tap2brg(int tap_unit, const char *ifbridge, int s)
686 bzero(&ifbr, sizeof(ifbr));
687 snprintf(ifbr.ifbr_ifsname, sizeof(ifbr.ifbr_ifsname),
690 bzero(&ifd, sizeof(ifd));
691 strlcpy(ifd.ifd_name, ifbridge, sizeof(ifd.ifd_name));
692 ifd.ifd_cmd = BRDGADD;
693 ifd.ifd_len = sizeof(ifbr);
694 ifd.ifd_data = &ifbr;
696 if (ioctl(s, SIOCSDRVSPEC, &ifd) < 0) {
698 * 'errno == EEXIST' means that the tap(4) is already
699 * a member of the bridge(4)
701 if (errno != EEXIST) {
702 warn("ioctl(%s, SIOCSDRVSPEC) failed", ifbridge);
709 #define TAPDEV_OFLAGS (O_RDWR | O_NONBLOCK)
711 /* XXX major()/minor() can't be used in vkernel */
712 #define TAPDEV_MAJOR(x) ((int)(((u_int)(x) >> 8) & 0xff))
713 #define TAPDEV_MINOR(x) ((int)((x) & 0xffff00ff))
715 #ifndef TAP_CDEV_MAJOR
716 #define TAP_CDEV_MAJOR 149
720 * Locate the first unused tap(4) device file if auto mode is requested,
721 * or open the user supplied device file, and bring up the corresponding
724 * NOTE: Only tap(4) device file is supported currently
728 netif_open_tap(const char *netif, int *tap_unit, int s)
730 char tap_dev[MAXPATHLEN];
736 if (strcmp(netif, "auto") == 0) {
740 * Find first unused tap(4) device file
743 snprintf(tap_dev, sizeof(tap_dev), "/dev/tap%d", i);
744 tap_fd = open(tap_dev, TAPDEV_OFLAGS);
745 if (tap_fd >= 0 || errno == ENOENT)
749 warnx("Unable to find a free tap(4)");
754 * User supplied tap(4) device file
756 if (netif[0] == '/') /* Absolute path */
757 strlcpy(tap_dev, netif, sizeof(tap_dev));
759 snprintf(tap_dev, sizeof(tap_dev), "/dev/%s", netif);
761 tap_fd = open(tap_dev, TAPDEV_OFLAGS);
763 warn("Unable to open %s", tap_dev);
769 * Check whether the device file is a tap(4)
772 if (fstat(tap_fd, &st) == 0 && S_ISCHR(st.st_mode) &&
773 TAPDEV_MAJOR(st.st_rdev) == TAP_CDEV_MAJOR) {
774 *tap_unit = TAPDEV_MINOR(st.st_rdev);
777 * Bring up the corresponding tap(4) interface
779 if (netif_set_tapflags(*tap_unit, IFF_UP, s) == 0)
782 warnx("%s is not a tap(4) device", tap_dev);
798 * Following syntax is supported,
799 * 1) x.x.x.x tap(4)'s address is x.x.x.x
801 * 2) x.x.x.x/z tap(4)'s address is x.x.x.x
802 * tap(4)'s netmask len is z
804 * 3) x.x.x.x:y.y.y.y tap(4)'s address is x.x.x.x
805 * pseudo netif's address is y.y.y.y
807 * 4) x.x.x.x:y.y.y.y/z tap(4)'s address is x.x.x.x
808 * pseudo netif's address is y.y.y.y
809 * tap(4) and pseudo netif's netmask len are z
811 * 5) bridgeX tap(4) will be added to bridgeX
813 * 6) bridgeX:y.y.y.y tap(4) will be added to bridgeX
814 * pseudo netif's address is y.y.y.y
816 * 7) bridgeX:y.y.y.y/z tap(4) will be added to bridgeX
817 * pseudo netif's address is y.y.y.y
818 * pseudo netif's netmask len is z
822 netif_init_tap(int tap_unit, in_addr_t *addr, in_addr_t *mask, int s)
824 in_addr_t tap_addr, netmask, netif_addr;
826 char *tok, *masklen_str, *ifbridge;
831 tok = strtok(NULL, ":/");
834 * Nothing special, simply use tap(4) as backend
839 if (inet_pton(AF_INET, tok, &tap_addr) > 0) {
841 * tap(4)'s address is supplied
846 * If there is next token, then it may be pseudo
847 * netif's address or netmask len for tap(4)
852 * Not tap(4)'s address, assume it as a bridge(4)
859 * If there is next token, then it must be pseudo
865 netmask = netif_addr = 0;
867 tok = strtok(NULL, ":/");
871 if (inet_pton(AF_INET, tok, &netif_addr) <= 0) {
872 if (next_netif_addr) {
873 warnx("Invalid pseudo netif address: %s", tok);
879 * Current token is not address, then it must be netmask len
884 * Current token is pseudo netif address, if there is next token
885 * it must be netmask len
887 masklen_str = strtok(NULL, "/");
890 /* Calculate netmask */
891 if (masklen_str != NULL) {
894 masklen = strtoul(masklen_str, NULL, 10);
895 if (masklen < 32 && masklen > 0) {
896 netmask = htonl(~((1LL << (32 - masklen)) - 1)
899 warnx("Invalid netmask len: %lu", masklen);
904 /* Make sure there is no more token left */
905 if (strtok(NULL, ":/") != NULL) {
906 warnx("Invalid argument to '-I'");
911 if (ifbridge == NULL) {
912 /* Set tap(4) address/netmask */
913 if (netif_set_tapaddr(tap_unit, tap_addr, netmask, s) < 0)
916 /* Tie tap(4) to bridge(4) */
917 if (netif_add_tap2brg(tap_unit, ifbridge, s) < 0)
927 * NetifInfo[] will be filled for pseudo netif initialization.
928 * NetifNum will be bumped to reflect the number of valid entries
933 init_netif(char *netifExp[], int netifExpNum)
937 if (netifExpNum == 0)
940 s = socket(AF_INET, SOCK_DGRAM, 0); /* for ioctl(SIOC) */
944 for (i = 0; i < netifExpNum; ++i) {
945 struct vknetif_info *info;
946 in_addr_t netif_addr, netif_mask;
947 int tap_fd, tap_unit;
950 netif = strtok(netifExp[i], ":");
952 warnx("Invalid argument to '-I'");
957 * Open tap(4) device file and bring up the
958 * corresponding interface
960 tap_fd = netif_open_tap(netif, &tap_unit, s);
965 * Initialize tap(4) and get address/netmask
968 * NB: Rest part of netifExp[i] is passed
969 * to netif_init_tap() implicitly.
971 if (netif_init_tap(tap_unit, &netif_addr, &netif_mask, s) < 0) {
973 * NB: Closing tap(4) device file will bring
974 * down the corresponding interface
980 info = &NetifInfo[NetifNum];
981 info->tap_fd = tap_fd;
982 info->tap_unit = tap_unit;
983 info->netif_addr = netif_addr;
984 info->netif_mask = netif_mask;
987 if (NetifNum >= VKNETIF_MAX) /* XXX will this happen? */
995 usage(const char *ctl)
1003 kprintf("cpu reset\n");
1010 kprintf("cpu halt\n");
1012 __asm__ __volatile("hlt");