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.31 2007/03/16 13:17:20 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;
80 struct vknetif_info NetifInfo[VKNETIF_MAX];
85 vm_offset_t virtual_start;
86 vm_offset_t virtual_end;
87 vm_offset_t kernel_vm_end;
88 vm_offset_t crashdumpmap;
89 vm_offset_t clean_sva;
90 vm_offset_t clean_eva;
91 struct msgbuf *msgbufp;
94 vpte_t *KernelPTA; /* Warning: Offset for direct VA translation */
95 u_int cpu_feature; /* XXX */
96 u_int tsc_present; /* XXX */
98 struct privatespace *CPU_prvspace;
100 static struct trapframe proc0_tf;
101 static void *proc0paddr;
103 static void init_sys_memory(char *imageFile);
104 static void init_kern_memory(void);
105 static void init_globaldata(void);
106 static void init_vkernel(void);
107 static void init_rootdevice(char *imageFile);
108 static void init_netif(char *netifFile[], int netifFileNum);
109 static void usage(const char *ctl);
112 * Kernel startup for virtual kernels - standard main()
115 main(int ac, char **av)
117 char *memImageFile = NULL;
118 char *rootImageFile = NULL;
119 char *netifFile[VKNETIF_MAX];
121 int netifFileNum = 0;
129 kernel_mem_readonly = 1;
131 while ((c = getopt(ac, av, "svm:r:e:i:I:U")) != -1) {
135 * name=value:name=value:name=value...
138 kern_envp = malloc(n + 2);
139 for (i = 0; i < n; ++i) {
140 if (optarg[i] == ':')
143 kern_envp[i] = optarg[i];
149 boothowto |= RB_SINGLE;
155 memImageFile = optarg;
158 if (netifFileNum < VKNETIF_MAX)
159 netifFile[netifFileNum++] = optarg;
162 rootImageFile = optarg;
165 Maxmem_bytes = strtoull(optarg, &suffix, 0);
182 usage("Bad maxmem option");
189 kernel_mem_readonly = 0;
195 init_sys_memory(memImageFile);
200 init_rootdevice(rootImageFile);
201 init_netif(netifFile, netifFileNum);
209 * Initialize system memory. This is the virtual kernel's 'RAM'.
213 init_sys_memory(char *imageFile)
220 * Figure out the system memory image size. If an image file was
221 * specified and -m was not specified, use the image file's size.
224 if (imageFile && stat(imageFile, &st) == 0 && Maxmem_bytes == 0)
225 Maxmem_bytes = (vm_paddr_t)st.st_size;
226 if ((imageFile == NULL || stat(imageFile, &st) < 0) &&
228 err(1, "Cannot create new memory file %s unless "
229 "system memory size is specified with -m",
235 * Maxmem must be known at this time
237 if (Maxmem_bytes < 32 * 1024 * 1024 || (Maxmem_bytes & SEG_MASK)) {
238 err(1, "Bad maxmem specification: 32MB minimum, "
239 "multiples of %dMB only",
240 SEG_SIZE / 1024 / 1024);
245 * Generate an image file name if necessary, then open/create the
246 * file exclusively locked. Do not allow multiple virtual kernels
247 * to use the same image file.
249 if (imageFile == NULL) {
250 for (i = 0; i < 1000000; ++i) {
251 asprintf(&imageFile, "/var/vkernel/memimg.%06d", i);
253 O_RDWR|O_CREAT|O_EXLOCK|O_NONBLOCK, 0644);
254 if (fd < 0 && errno == EWOULDBLOCK) {
261 fd = open(imageFile, O_RDWR|O_CREAT|O_EXLOCK|O_NONBLOCK, 0644);
263 printf("Using memory file: %s\n", imageFile);
264 if (fd < 0 || fstat(fd, &st) < 0) {
265 err(1, "Unable to open/create %s", imageFile);
270 * Truncate or extend the file as necessary.
272 if (st.st_size > Maxmem_bytes) {
273 ftruncate(fd, Maxmem_bytes);
274 } else if (st.st_size < Maxmem_bytes) {
276 off_t off = st.st_size & ~SEG_MASK;
278 kprintf("%s: Reserving blocks for memory image\n", imageFile);
279 zmem = malloc(SEG_SIZE);
280 bzero(zmem, SEG_SIZE);
281 lseek(fd, off, SEEK_SET);
282 while (off < Maxmem_bytes) {
283 if (write(fd, zmem, SEG_SIZE) != SEG_SIZE) {
284 err(1, "Unable to reserve blocks for memory image");
290 err(1, "Unable to reserve blocks for memory image");
294 Maxmem = Maxmem_bytes >> PAGE_SHIFT;
298 * Initialize kernel memory. This reserves kernel virtual memory by using
303 init_kern_memory(void)
311 * Memory map our kernel virtual memory space. Note that the
312 * kernel image itself is not made part of this memory for the
315 * The memory map must be segment-aligned so we can properly
318 base = mmap((void *)0x40000000, KERNEL_KVA_SIZE, PROT_READ|PROT_WRITE,
319 MAP_FILE|MAP_SHARED|MAP_VPAGETABLE, MemImageFd, 0);
320 if (base == MAP_FAILED) {
321 err(1, "Unable to mmap() kernel virtual memory!");
324 madvise(base, KERNEL_KVA_SIZE, MADV_NOSYNC);
325 KvaStart = (vm_offset_t)base;
326 KvaSize = KERNEL_KVA_SIZE;
327 KvaEnd = KvaStart + KvaSize;
330 * Create a top-level page table self-mapping itself.
332 * Initialize the page directory at physical page index 0 to point
333 * to an array of page table pages starting at physical page index 1
335 lseek(MemImageFd, 0L, 0);
336 for (i = 0; i < KERNEL_KVA_SIZE / SEG_SIZE; ++i) {
337 pte = ((i + 1) * PAGE_SIZE) | VPTE_V | VPTE_R | VPTE_W;
338 write(MemImageFd, &pte, sizeof(pte));
342 * Initialize the PTEs in the page table pages required to map the
343 * page table itself. This includes mapping the page directory page
344 * at the base so we go one more loop then normal.
346 lseek(MemImageFd, PAGE_SIZE, 0);
347 for (i = 0; i <= KERNEL_KVA_SIZE / SEG_SIZE * sizeof(vpte_t); ++i) {
348 pte = (i * PAGE_SIZE) | VPTE_V | VPTE_R | VPTE_W;
349 write(MemImageFd, &pte, sizeof(pte));
353 * Initialize remaining PTEs to 0. We may be reusing a memory image
354 * file. This is approximately a megabyte.
356 i = (KERNEL_KVA_SIZE / PAGE_SIZE - i) * sizeof(pte);
357 zero = malloc(PAGE_SIZE);
358 bzero(zero, PAGE_SIZE);
360 write(MemImageFd, zero, (i > PAGE_SIZE) ? PAGE_SIZE : i);
361 i = i - ((i > PAGE_SIZE) ? PAGE_SIZE : i);
366 * Enable the page table and calculate pointers to our self-map
367 * for easy kernel page table manipulation.
369 * KernelPTA must be offset so we can do direct VA translations
371 mcontrol(base, KERNEL_KVA_SIZE, MADV_SETMAP,
372 0 | VPTE_R | VPTE_W | VPTE_V);
373 KernelPTD = (vpte_t *)base; /* pg directory */
374 KernelPTA = (vpte_t *)((char *)base + PAGE_SIZE); /* pg table pages */
375 KernelPTA -= KvaStart >> PAGE_SHIFT;
378 * phys_avail[] represents unallocated physical memory. MI code
379 * will use phys_avail[] to create the vm_page array.
381 phys_avail[0] = PAGE_SIZE +
382 KERNEL_KVA_SIZE / PAGE_SIZE * sizeof(vpte_t);
383 phys_avail[0] = (phys_avail[0] + PAGE_MASK) & ~(vm_paddr_t)PAGE_MASK;
384 phys_avail[1] = Maxmem_bytes;
387 * (virtual_start, virtual_end) represent unallocated kernel virtual
388 * memory. MI code will create kernel_map using these parameters.
390 virtual_start = KvaStart + PAGE_SIZE +
391 KERNEL_KVA_SIZE / PAGE_SIZE * sizeof(vpte_t);
392 virtual_start = (virtual_start + PAGE_MASK) & ~(vm_offset_t)PAGE_MASK;
393 virtual_end = KvaStart + KERNEL_KVA_SIZE;
396 * kernel_vm_end could be set to virtual_end but we want some
397 * indication of how much of the kernel_map we've used, so
398 * set it low and let pmap_growkernel increase it even though we
399 * don't need to create any new page table pages.
401 kernel_vm_end = virtual_start;
404 * Allocate space for process 0's UAREA.
406 proc0paddr = (void *)virtual_start;
407 for (i = 0; i < UPAGES; ++i) {
408 pmap_kenter_quick(virtual_start, phys_avail[0]);
409 virtual_start += PAGE_SIZE;
410 phys_avail[0] += PAGE_SIZE;
416 crashdumpmap = virtual_start;
417 virtual_start += MAXDUMPPGS * PAGE_SIZE;
420 * msgbufp maps the system message buffer
422 assert((MSGBUF_SIZE & PAGE_MASK) == 0);
423 msgbufp = (void *)virtual_start;
424 for (i = 0; i < (MSGBUF_SIZE >> PAGE_SHIFT); ++i) {
425 pmap_kenter_quick(virtual_start, phys_avail[0]);
426 virtual_start += PAGE_SIZE;
427 phys_avail[0] += PAGE_SIZE;
429 msgbufinit(msgbufp, MSGBUF_SIZE);
432 * used by kern_memio for /dev/mem access
434 ptvmmap = (caddr_t)virtual_start;
435 virtual_start += PAGE_SIZE;
438 * Bootstrap the kernel_pmap
444 * Map the per-cpu globaldata for cpu #0. Allocate the space using
445 * virtual_start and phys_avail[0]
449 init_globaldata(void)
456 * Reserve enough KVA to cover possible cpus. This is a considerable
457 * amount of KVA since the privatespace structure includes two
458 * whole page table mappings.
460 virtual_start = (virtual_start + SEG_MASK) & ~(vm_offset_t)SEG_MASK;
461 CPU_prvspace = (void *)virtual_start;
462 virtual_start += sizeof(struct privatespace) * SMP_MAXCPU;
465 * Allocate enough physical memory to cover the mdglobaldata
466 * portion of the space and the idle stack and map the pages
467 * into KVA. For cpu #0 only.
469 for (i = 0; i < sizeof(struct mdglobaldata); i += PAGE_SIZE) {
471 va = (vm_offset_t)&CPU_prvspace[0].mdglobaldata + i;
472 pmap_kenter_quick(va, pa);
473 phys_avail[0] += PAGE_SIZE;
475 for (i = 0; i < sizeof(CPU_prvspace[0].idlestack); i += PAGE_SIZE) {
477 va = (vm_offset_t)&CPU_prvspace[0].idlestack + i;
478 pmap_kenter_quick(va, pa);
479 phys_avail[0] += PAGE_SIZE;
483 * Setup the %gs for cpu #0. The mycpu macro works after this
486 tls_set_fs(&CPU_prvspace[0], sizeof(struct privatespace));
490 * Initialize very low level systems including thread0, proc0, etc.
496 struct mdglobaldata *gd;
498 gd = &CPU_prvspace[0].mdglobaldata;
499 bzero(gd, sizeof(*gd));
501 gd->mi.gd_curthread = &thread0;
502 thread0.td_gd = &gd->mi;
506 gd->mi.gd_prvspace = &CPU_prvspace[0];
507 mi_gdinit(&gd->mi, 0);
509 mi_proc0init(&gd->mi, proc0paddr);
510 lwp0.lwp_md.md_regs = &proc0_tf;
515 #if 0 /* #ifdef DDB */
517 if (boothowto & RB_KDB)
518 Debugger("Boot flags requested debugger");
521 initializecpu(); /* Initialize CPU registers */
523 init_param2((phys_avail[1] - phys_avail[0]) / PAGE_SIZE);
527 * Map the message buffer
529 for (off = 0; off < round_page(MSGBUF_SIZE); off += PAGE_SIZE)
530 pmap_kenter((vm_offset_t)msgbufp + off, avail_end + off);
531 msgbufinit(msgbufp, MSGBUF_SIZE);
534 thread0.td_pcb_cr3 ... MMU
535 lwp0.lwp_md.md_regs = &proc0_tf;
540 * The root filesystem path for the virtual kernel is optional. If specified
541 * it points to a filesystem image.
543 * The virtual kernel caches data from our 'disk' just like a normal kernel,
544 * so we do not really want the real kernel to cache the data too. Use
545 * O_DIRECT to remove the duplication.
549 init_rootdevice(char *imageFile)
554 RootImageFd = open(imageFile, O_RDWR|O_DIRECT, 0644);
555 if (RootImageFd < 0 || fstat(RootImageFd, &st) < 0) {
556 err(1, "Unable to open/create %s", imageFile);
559 rootdevnames[0] = "ufs:vkd0a";
565 netif_set_tapflags(int tap_unit, int f, int s)
570 bzero(&ifr, sizeof(ifr));
572 snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "tap%d", tap_unit);
573 if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {
574 warn("tap%d: ioctl(SIOCGIFFLAGS) failed", tap_unit);
581 * If the flags are already set/cleared, then we return
582 * immediately to avoid extra syscalls
584 flags = (ifr.ifr_flags & 0xffff) | (ifr.ifr_flagshigh << 16);
588 if ((flags & f) == 0)
599 * Fix up ifreq.ifr_name, since it may be trashed
600 * in previous ioctl(SIOCGIFFLAGS)
602 snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "tap%d", tap_unit);
604 ifr.ifr_flags = flags & 0xffff;
605 ifr.ifr_flagshigh = flags >> 16;
606 if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0) {
607 warn("tap%d: ioctl(SIOCSIFFLAGS) failed", tap_unit);
615 netif_set_tapaddr(int tap_unit, in_addr_t addr, in_addr_t mask, int s)
617 struct ifaliasreq ifra;
618 struct sockaddr_in *in;
620 bzero(&ifra, sizeof(ifra));
621 snprintf(ifra.ifra_name, sizeof(ifra.ifra_name), "tap%d", tap_unit);
624 in = (struct sockaddr_in *)&ifra.ifra_addr;
625 in->sin_family = AF_INET;
626 in->sin_len = sizeof(*in);
627 in->sin_addr.s_addr = addr;
631 in = (struct sockaddr_in *)&ifra.ifra_mask;
632 in->sin_len = sizeof(*in);
633 in->sin_addr.s_addr = mask;
636 if (ioctl(s, SIOCAIFADDR, &ifra) < 0) {
637 warn("tap%d: ioctl(SIOCAIFADDR) failed", tap_unit);
645 netif_add_tap2brg(int tap_unit, const char *ifbridge, int s)
650 bzero(&ifbr, sizeof(ifbr));
651 snprintf(ifbr.ifbr_ifsname, sizeof(ifbr.ifbr_ifsname),
654 bzero(&ifd, sizeof(ifd));
655 strlcpy(ifd.ifd_name, ifbridge, sizeof(ifd.ifd_name));
656 ifd.ifd_cmd = BRDGADD;
657 ifd.ifd_len = sizeof(ifbr);
658 ifd.ifd_data = &ifbr;
660 if (ioctl(s, SIOCSDRVSPEC, &ifd) < 0) {
662 * 'errno == EEXIST' means that the tap(4) is already
663 * a member of the bridge(4)
665 if (errno != EEXIST) {
666 warn("ioctl(%s, SIOCSDRVSPEC) failed", ifbridge);
673 #define TAPDEV_OFLAGS (O_RDWR | O_NONBLOCK)
675 /* XXX major()/minor() can't be used in vkernel */
676 #define TAPDEV_MAJOR(x) ((int)(((u_int)(x) >> 8) & 0xff))
677 #define TAPDEV_MINOR(x) ((int)((x) & 0xffff00ff))
679 #ifndef TAP_CDEV_MAJOR
680 #define TAP_CDEV_MAJOR 149
684 * Locate the first unused tap(4) device file if auto mode is requested,
685 * or open the user supplied device file, and bring up the corresponding
688 * NOTE: Only tap(4) device file is supported currently
692 netif_open_tap(const char *netif, int *tap_unit, int s)
694 char tap_dev[MAXPATHLEN];
700 if (strcmp(netif, "auto") == 0) {
704 * Find first unused tap(4) device file
707 snprintf(tap_dev, sizeof(tap_dev), "/dev/tap%d", i);
708 tap_fd = open(tap_dev, TAPDEV_OFLAGS);
709 if (tap_fd >= 0 || errno == ENOENT)
713 warnx("Unable to find a free tap(4)");
718 * User supplied tap(4) device file
720 if (netif[0] == '/') /* Absolute path */
721 strlcpy(tap_dev, netif, sizeof(tap_dev));
723 snprintf(tap_dev, sizeof(tap_dev), "/dev/%s", netif);
725 tap_fd = open(tap_dev, TAPDEV_OFLAGS);
727 warn("Unable to open %s", tap_dev);
733 * Check whether the device file is a tap(4)
736 if (fstat(tap_fd, &st) == 0 && S_ISCHR(st.st_mode) &&
737 TAPDEV_MAJOR(st.st_rdev) == TAP_CDEV_MAJOR) {
738 *tap_unit = TAPDEV_MINOR(st.st_rdev);
741 * Bring up the corresponding tap(4) interface
743 if (netif_set_tapflags(*tap_unit, IFF_UP, s) == 0)
746 warnx("%s is not a tap(4) device", tap_dev);
762 * Following syntax is supported,
763 * 1) x.x.x.x tap(4)'s address is x.x.x.x
765 * 2) x.x.x.x/z tap(4)'s address is x.x.x.x
766 * tap(4)'s netmask len is z
768 * 3) x.x.x.x:y.y.y.y tap(4)'s address is x.x.x.x
769 * pseudo netif's address is y.y.y.y
771 * 4) x.x.x.x:y.y.y.y/z tap(4)'s address is x.x.x.x
772 * pseudo netif's address is y.y.y.y
773 * tap(4) and pseudo netif's netmask len are z
775 * 5) bridgeX tap(4) will be added to bridgeX
777 * 6) bridgeX:y.y.y.y tap(4) will be added to bridgeX
778 * pseudo netif's address is y.y.y.y
780 * 7) bridgeX:y.y.y.y/z tap(4) will be added to bridgeX
781 * pseudo netif's address is y.y.y.y
782 * pseudo netif's netmask len is z
786 netif_init_tap(int tap_unit, in_addr_t *addr, in_addr_t *mask, int s)
788 in_addr_t tap_addr, netmask, netif_addr;
790 char *tok, *masklen_str, *ifbridge;
795 tok = strtok(NULL, ":/");
798 * Nothing special, simply use tap(4) as backend
803 if (inet_pton(AF_INET, tok, &tap_addr) > 0) {
805 * tap(4)'s address is supplied
810 * If there is next token, then it may be pseudo
811 * netif's address or netmask len for tap(4)
816 * Not tap(4)'s address, assume it as a bridge(4)
823 * If there is next token, then it must be pseudo
829 netmask = netif_addr = 0;
831 tok = strtok(NULL, ":/");
835 if (inet_pton(AF_INET, tok, &netif_addr) <= 0) {
836 if (next_netif_addr) {
837 warnx("Invalid pseudo netif address: %s", tok);
843 * Current token is not address, then it must be netmask len
848 * Current token is pseudo netif address, if there is next token
849 * it must be netmask len
851 masklen_str = strtok(NULL, "/");
854 /* Calculate netmask */
855 if (masklen_str != NULL) {
858 masklen = strtoul(masklen_str, NULL, 10);
859 if (masklen < 32 && masklen > 0) {
860 netmask = htonl(~((1LL << (32 - masklen)) - 1)
863 warnx("Invalid netmask len: %lu", masklen);
868 /* Make sure there is no more token left */
869 if (strtok(NULL, ":/") != NULL) {
870 warnx("Invalid argument to '-I'");
875 if (ifbridge == NULL) {
876 /* Set tap(4) address/netmask */
877 if (netif_set_tapaddr(tap_unit, tap_addr, netmask, s) < 0)
880 /* Tie tap(4) to bridge(4) */
881 if (netif_add_tap2brg(tap_unit, ifbridge, s) < 0)
891 * NetifInfo[] will be filled for pseudo netif initialization.
892 * NetifNum will be bumped to reflect the number of valid entries
897 init_netif(char *netifExp[], int netifExpNum)
901 if (netifExpNum == 0)
904 s = socket(AF_INET, SOCK_DGRAM, 0); /* for ioctl(SIOC) */
908 for (i = 0; i < netifExpNum; ++i) {
909 struct vknetif_info *info;
910 in_addr_t netif_addr, netif_mask;
911 int tap_fd, tap_unit;
914 netif = strtok(netifExp[i], ":");
916 warnx("Invalide argument to '-I'");
921 * Open tap(4) device file and bring up the
922 * corresponding interface
924 tap_fd = netif_open_tap(netif, &tap_unit, s);
929 * Initialize tap(4) and get address/netmask
932 * NB: Rest part of netifExp[i] is passed
933 * to netif_init_tap() implicitly.
935 if (netif_init_tap(tap_unit, &netif_addr, &netif_mask, s) < 0) {
937 * NB: Closing tap(4) device file will bring
938 * down the corresponding interface
944 info = &NetifInfo[NetifNum];
945 info->tap_fd = tap_fd;
946 info->tap_unit = tap_unit;
947 info->netif_addr = netif_addr;
948 info->netif_mask = netif_mask;
951 if (NetifNum >= VKNETIF_MAX) /* XXX will this happen? */
959 usage(const char *ctl)
967 kprintf("cpu reset\n");
974 kprintf("cpu halt\n");
976 __asm__ __volatile("hlt");