qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] PALcode fixes for guest OS console initialization
@ 2021-06-13 21:09 Jason Thorpe
  2021-06-13 21:09 ` [PATCH v2 1/1] Provide a minimal Console Terminal Block in the HWRPB Jason Thorpe
  2021-06-15  0:29 ` [PATCH v2 0/1] PALcode fixes for guest OS console initialization Jason Thorpe
  0 siblings, 2 replies; 4+ messages in thread
From: Jason Thorpe @ 2021-06-13 21:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jason Thorpe, richard.henderson

This is a follow-up on my previous set of patches for the Qemu PALcode,
which were merged except for the CTB patch.  The patch has incorporated
review feedback, but there is still some research going on about how
real DEC SRM initializes a particular field in various circumstances;
this is my best guess based on available documentation and observed
behavior of real machines, and is sufficient for the BSD operating systems.

Jason Thorpe (1):
  Provide a minimal Console Terminal Block in the HWRPB.

 hwrpb.h  | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 init.c   | 36 +++++++++++++++++++++++++++++++++---
 protos.h |  2 ++
 vgaio.c  |  2 ++
 4 files changed, 91 insertions(+), 3 deletions(-)

-- 
2.30.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/1] Provide a minimal Console Terminal Block in the HWRPB.
  2021-06-13 21:09 [PATCH v2 0/1] PALcode fixes for guest OS console initialization Jason Thorpe
@ 2021-06-13 21:09 ` Jason Thorpe
  2021-06-15  0:29 ` [PATCH v2 0/1] PALcode fixes for guest OS console initialization Jason Thorpe
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Thorpe @ 2021-06-13 21:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jason Thorpe, richard.henderson

Provide a minimal Console Terminal Block in the HWRPB so that operating
systems that depend on it can correctly initialize the console device.
This is suffucient, at least, for the BSD operating systems, but may not
be sufficient for Digital UNIX.

In addition to defining and filling out the structures, there are a couple
of other key changes:

- Redefine the a2 register passed by Qemu at start-up to also include
  some configuration flags, in addition to the CPU count, and define
  a flag to mirror the "-nographics" option.

- We need to initialize the HWRPB *after* initializing VGA, so that
  we'll know if a VGA device is present and in which slot for filling
  out the CTB.

Signed-off-by: Jason Thorpe <thorpej@me.com>
---
 hwrpb.h  | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 init.c   | 36 +++++++++++++++++++++++++++++++++---
 protos.h |  2 ++
 vgaio.c  |  2 ++
 4 files changed, 91 insertions(+), 3 deletions(-)

diff --git a/hwrpb.h b/hwrpb.h
index 2166bad..7b6efc6 100644
--- a/hwrpb.h
+++ b/hwrpb.h
@@ -146,6 +146,60 @@ struct crb_struct {
 	struct vf_map_struct map[1];
 };
 
+struct ctb_struct {
+	unsigned long type;
+	unsigned long unit;
+	unsigned long res0;
+	unsigned long len;
+	unsigned long ipl;
+	unsigned long tintr_vec;
+	unsigned long rintr_vec;
+	unsigned long term_type;
+	unsigned long keybd_type;
+	unsigned long keybd_trans;
+	unsigned long keybd_map;
+	unsigned long keybd_state;
+	unsigned long keybd_last;
+	unsigned long font_us;
+	unsigned long font_mcs;
+	unsigned long font_width;
+	unsigned long font_height;
+	unsigned long mon_width;
+	unsigned long mon_height;
+	unsigned long dpi;
+	unsigned long planes;
+	unsigned long cur_width;
+	unsigned long cur_height;
+	unsigned long head_cnt;
+	unsigned long opwindow;
+	unsigned long head_offset;
+	unsigned long putchar;
+	unsigned long io_state;
+	unsigned long listen_state;
+	unsigned long xaddr;
+	unsigned long turboslot;
+	unsigned long server_off;
+	unsigned long line_off;
+	unsigned char csd;
+};
+
+#define CTB_NONE		0x00
+#define CTB_PRINTERPORT		0x02
+#define CTB_GRAPHICS		0x03
+#define CTB_MULTIPURPOSE	0x04
+
+/*
+ * Format of the Console Terminal Block MULTIPURPOSE `turboslot' field:
+ *
+ *  63                   40 39       32 31     24 23      16 15   8 7    0
+ *  |      reserved        |  channel  |  hose   | bus type |  bus | slot |
+ */
+
+#define CTB_TURBOSLOT_TYPE_TC           0       /* TURBOchannel */
+#define CTB_TURBOSLOT_TYPE_ISA          1       /* ISA */
+#define CTB_TURBOSLOT_TYPE_EISA         2       /* EISA */
+#define CTB_TURBOSLOT_TYPE_PCI          3       /* PCI */
+
 struct memclust_struct {
 	unsigned long start_pfn;
 	unsigned long numpages;
diff --git a/init.c b/init.c
index 6edfdf2..a58734f 100644
--- a/init.c
+++ b/init.c
@@ -36,11 +36,20 @@
 
 #define HZ	1024
 
+/* Upon entry, register a2 contains configuration information from the VM:
+
+   bits 0-5 -- ncpus
+   bit  6   -- "nographics" option (used to initialize CTB)  */
+
+#define CONFIG_NCPUS(x)      ((x) & 63)
+#define CONFIG_NOGRAPHICS(x) ((x) & (1ull << 6))
+
 struct hwrpb_combine {
   struct hwrpb_struct hwrpb;
   struct percpu_struct processor[4];
   struct memdesc_struct md;
   struct memclust_struct mc[2];
+  struct ctb_struct ctb;
   struct crb_struct crb;
   struct procdesc_struct proc_dispatch;
   struct procdesc_struct proc_fixup;
@@ -59,6 +68,8 @@ struct hwrpb_combine hwrpb __attribute__((aligned(PAGE_SIZE)));
 
 void *last_alloc;
 bool have_vga;
+unsigned int pci_vga_bus;
+unsigned int pci_vga_dev;
 
 static void *
 alloc (unsigned long size, unsigned long align)
@@ -136,12 +147,13 @@ init_page_table(void)
 }
 
 static void
-init_hwrpb (unsigned long memsize, unsigned long cpus)
+init_hwrpb (unsigned long memsize, unsigned long config)
 {
   unsigned long pal_pages;
   unsigned long amask;
   unsigned long i;
   unsigned long proc_type = EV4_CPU;
+  unsigned long cpus = CONFIG_NCPUS(config);
   
   hwrpb.hwrpb.phys_addr = PA(&hwrpb);
 
@@ -226,6 +238,23 @@ init_hwrpb (unsigned long memsize, unsigned long cpus)
   hwrpb.mc[1].start_pfn = pal_pages;
   hwrpb.mc[1].numpages = (memsize >> PAGE_SHIFT) - pal_pages;
 
+  hwrpb.hwrpb.ctbt_offset = offsetof(struct hwrpb_combine, ctb);
+  memset(&hwrpb.ctb, 0, sizeof(hwrpb.ctb));
+  hwrpb.hwrpb.ctb_size = sizeof(hwrpb.ctb);
+  hwrpb.ctb.len = sizeof(hwrpb.ctb) - offsetof(struct ctb_struct, ipl);
+  if (have_vga && !CONFIG_NOGRAPHICS(config))
+    {
+      hwrpb.ctb.type = CTB_MULTIPURPOSE;
+      hwrpb.ctb.term_type = CTB_GRAPHICS;
+      hwrpb.ctb.turboslot = (CTB_TURBOSLOT_TYPE_PCI << 16) |
+			    (pci_vga_bus << 8) | pci_vga_dev;
+    }
+  else
+    {
+      hwrpb.ctb.type = CTB_PRINTERPORT;
+      hwrpb.ctb.term_type = CTB_PRINTERPORT;
+    }
+
   hwrpb.hwrpb.crb_offset = offsetof(struct hwrpb_combine, crb);
   hwrpb.crb.dispatch_va = &hwrpb.proc_dispatch;
   hwrpb.crb.dispatch_pa = PA(&hwrpb.proc_dispatch);
@@ -302,18 +331,19 @@ swppal(void *entry, void *pcb, unsigned long vptptr, unsigned long pv)
 }
 
 void
-do_start(unsigned long memsize, void (*kernel_entry)(void), unsigned long cpus)
+do_start(unsigned long memsize, void (*kernel_entry)(void),
+         unsigned long config)
 {
   last_alloc = _end;
 
   init_page_table();
-  init_hwrpb(memsize, cpus);
   init_pcb();
   init_i8259();
   uart_init();
   ps2port_setup();
   pci_setup();
   vgahw_init();
+  init_hwrpb(memsize, config);
 
   void *new_pc = kernel_entry ? kernel_entry : do_console;
 
diff --git a/protos.h b/protos.h
index 0d90be8..44ad233 100644
--- a/protos.h
+++ b/protos.h
@@ -222,6 +222,8 @@ extern unsigned long crb_fixup(unsigned long vptptr, unsigned long hwrpb);
  */
 
 extern bool have_vga;
+extern unsigned int pci_vga_bus;
+extern unsigned int pci_vga_dev;
 
 extern void do_console(void);
 extern void entInt(void);
diff --git a/vgaio.c b/vgaio.c
index 2dd7eb7..1fb0d52 100644
--- a/vgaio.c
+++ b/vgaio.c
@@ -570,6 +570,8 @@ vgahw_init(void)
 
  found:
   have_vga = 1;
+  pci_vga_bus = PCI_BUS(bdf);
+  pci_vga_dev = PCI_SLOT(bdf);
 
   vmode_g = find_vga_entry(3);
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/1] PALcode fixes for guest OS console initialization
  2021-06-13 21:09 [PATCH v2 0/1] PALcode fixes for guest OS console initialization Jason Thorpe
  2021-06-13 21:09 ` [PATCH v2 1/1] Provide a minimal Console Terminal Block in the HWRPB Jason Thorpe
@ 2021-06-15  0:29 ` Jason Thorpe
  2021-06-15  3:51   ` Richard Henderson
  1 sibling, 1 reply; 4+ messages in thread
From: Jason Thorpe @ 2021-06-15  0:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson



> On Jun 13, 2021, at 2:09 PM, Jason Thorpe <thorpej@me.com> wrote:
> 
> but there is still some research going on about how
> real DEC SRM initializes a particular field in various circumstances;
> this is my best guess based on available documentation and observed
> behavior of real machines, and is sufficient for the BSD operating systems.

FWIW, I have since confirmed my hypothesis about how genuine DEC SRM fills in the "type" and "term_type" fields on 2 different generations of PCI-based Alpha systems (i.e. it matches the patch submitted here).

-- thorpej



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/1] PALcode fixes for guest OS console initialization
  2021-06-15  0:29 ` [PATCH v2 0/1] PALcode fixes for guest OS console initialization Jason Thorpe
@ 2021-06-15  3:51   ` Richard Henderson
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2021-06-15  3:51 UTC (permalink / raw)
  To: Jason Thorpe, qemu-devel

On 6/14/21 5:29 PM, Jason Thorpe wrote:
> 
> 
>> On Jun 13, 2021, at 2:09 PM, Jason Thorpe <thorpej@me.com> wrote:
>>
>> but there is still some research going on about how
>> real DEC SRM initializes a particular field in various circumstances;
>> this is my best guess based on available documentation and observed
>> behavior of real machines, and is sufficient for the BSD operating systems.
> 
> FWIW, I have since confirmed my hypothesis about how genuine DEC SRM fills in the "type" and "term_type" fields on 2 different generations of PCI-based Alpha systems (i.e. it matches the patch submitted here).

Excellent, thanks.  Queued.


r~



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-15  3:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-13 21:09 [PATCH v2 0/1] PALcode fixes for guest OS console initialization Jason Thorpe
2021-06-13 21:09 ` [PATCH v2 1/1] Provide a minimal Console Terminal Block in the HWRPB Jason Thorpe
2021-06-15  0:29 ` [PATCH v2 0/1] PALcode fixes for guest OS console initialization Jason Thorpe
2021-06-15  3:51   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).