~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/m68k/virt/config.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 
  3 #include <linux/reboot.h>
  4 #include <linux/serial_core.h>
  5 #include <clocksource/timer-goldfish.h>
  6 
  7 #include <asm/bootinfo.h>
  8 #include <asm/bootinfo-virt.h>
  9 #include <asm/byteorder.h>
 10 #include <asm/machdep.h>
 11 #include <asm/virt.h>
 12 #include <asm/config.h>
 13 
 14 struct virt_booter_data virt_bi_data;
 15 
 16 #define VIRT_CTRL_REG_FEATURES  0x00
 17 #define VIRT_CTRL_REG_CMD       0x04
 18 
 19 static struct resource ctrlres;
 20 
 21 enum {
 22         CMD_NOOP,
 23         CMD_RESET,
 24         CMD_HALT,
 25         CMD_PANIC,
 26 };
 27 
 28 static void virt_get_model(char *str)
 29 {
 30         /* str is 80 characters long */
 31         sprintf(str, "QEMU Virtual M68K Machine (%u.%u.%u)",
 32                 (u8)(virt_bi_data.qemu_version >> 24),
 33                 (u8)(virt_bi_data.qemu_version >> 16),
 34                 (u8)(virt_bi_data.qemu_version >> 8));
 35 }
 36 
 37 static void virt_halt(void)
 38 {
 39         void __iomem *base = (void __iomem *)virt_bi_data.ctrl.mmio;
 40 
 41         iowrite32be(CMD_HALT, base + VIRT_CTRL_REG_CMD);
 42         local_irq_disable();
 43         while (1)
 44                 ;
 45 }
 46 
 47 static void virt_reset(void)
 48 {
 49         void __iomem *base = (void __iomem *)virt_bi_data.ctrl.mmio;
 50 
 51         iowrite32be(CMD_RESET, base + VIRT_CTRL_REG_CMD);
 52         local_irq_disable();
 53         while (1)
 54                 ;
 55 }
 56 
 57 /*
 58  * Parse a virtual-m68k-specific record in the bootinfo
 59  */
 60 
 61 int __init virt_parse_bootinfo(const struct bi_record *record)
 62 {
 63         int unknown = 0;
 64         const void *data = record->data;
 65 
 66         switch (be16_to_cpu(record->tag)) {
 67         case BI_VIRT_QEMU_VERSION:
 68                 virt_bi_data.qemu_version = be32_to_cpup(data);
 69                 break;
 70         case BI_VIRT_GF_PIC_BASE:
 71                 virt_bi_data.pic.mmio = be32_to_cpup(data);
 72                 data += 4;
 73                 virt_bi_data.pic.irq = be32_to_cpup(data);
 74                 break;
 75         case BI_VIRT_GF_RTC_BASE:
 76                 virt_bi_data.rtc.mmio = be32_to_cpup(data);
 77                 data += 4;
 78                 virt_bi_data.rtc.irq = be32_to_cpup(data);
 79                 break;
 80         case BI_VIRT_GF_TTY_BASE:
 81                 virt_bi_data.tty.mmio = be32_to_cpup(data);
 82                 data += 4;
 83                 virt_bi_data.tty.irq = be32_to_cpup(data);
 84                 break;
 85         case BI_VIRT_CTRL_BASE:
 86                 virt_bi_data.ctrl.mmio = be32_to_cpup(data);
 87                 data += 4;
 88                 virt_bi_data.ctrl.irq = be32_to_cpup(data);
 89                 break;
 90         case BI_VIRT_VIRTIO_BASE:
 91                 virt_bi_data.virtio.mmio = be32_to_cpup(data);
 92                 data += 4;
 93                 virt_bi_data.virtio.irq = be32_to_cpup(data);
 94                 break;
 95         default:
 96                 unknown = 1;
 97                 break;
 98         }
 99         return unknown;
100 }
101 
102 static void __init virt_sched_init(void)
103 {
104         goldfish_timer_init(virt_bi_data.rtc.irq,
105                             (void __iomem *)virt_bi_data.rtc.mmio);
106 }
107 
108 void __init config_virt(void)
109 {
110         char earlycon[24];
111 
112         snprintf(earlycon, sizeof(earlycon), "early_gf_tty,0x%08x",
113                  virt_bi_data.tty.mmio);
114         setup_earlycon(earlycon);
115 
116         ctrlres = (struct resource)
117                    DEFINE_RES_MEM_NAMED(virt_bi_data.ctrl.mmio, 0x100,
118                                         "virtctrl");
119 
120         if (request_resource(&iomem_resource, &ctrlres)) {
121                 pr_err("Cannot allocate virt controller resource\n");
122                 return;
123         }
124 
125         mach_init_IRQ = virt_init_IRQ;
126         mach_sched_init = virt_sched_init;
127         mach_get_model = virt_get_model;
128         mach_reset = virt_reset;
129         mach_halt = virt_halt;
130 
131         register_platform_power_off(virt_halt);
132 }
133 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php