aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2009-07-26 19:33:13 -0400
committerKevin O'Connor <kevin@koconnor.net>2009-07-26 19:33:13 -0400
commite54ee3800df72c2742f486abf437e75c2b56182c (patch)
tree1cf4862f4819a6bd0dae0a7b05770fc3937b21f8
parente773930ea4f37bca9334a157e86e70f14234888f (diff)
downloadseabios-e54ee3800df72c2742f486abf437e75c2b56182c.zip
seabios-e54ee3800df72c2742f486abf437e75c2b56182c.tar.gz
seabios-e54ee3800df72c2742f486abf437e75c2b56182c.tar.bz2
Add PMM stubs.
Add initial code for Post Memory Manager - it's just the stubs for now. Also, fix PnP entry point not clearing irqs and direction flags.
-rw-r--r--Makefile2
-rw-r--r--src/config.h3
-rw-r--r--src/pmm.c117
-rw-r--r--src/post.c7
-rw-r--r--src/romlayout.S31
-rw-r--r--src/util.h4
6 files changed, 161 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 41e6514..2e2ba1d 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ OUT=out/
# Source files
SRCBOTH=output.c util.c floppy.c ata.c misc.c mouse.c kbd.c pci.c \
serial.c clock.c pic.c cdrom.c ps2port.c smp.c resume.c \
- pnpbios.c pirtable.c vgahooks.c
+ pnpbios.c pirtable.c vgahooks.c pmm.c
SRC16=$(SRCBOTH) system.c disk.c apm.c pcibios.c font.c
SRC32=$(SRCBOTH) post.c shadow.c memmap.c coreboot.c boot.c \
acpi.c smm.c mptable.c smbios.c pciinit.c optionroms.c mtrr.c \
diff --git a/src/config.h b/src/config.h
index 6f19107..36f2a72 100644
--- a/src/config.h
+++ b/src/config.h
@@ -39,6 +39,8 @@
#define CONFIG_APMBIOS 1
// Support PnP BIOS entry point.
#define CONFIG_PNPBIOS 1
+// Support Post Memory Manager (PMM) entry point.
+#define CONFIG_PMM 0
// Support int 19/18 system bootup support
#define CONFIG_BOOT 1
// Support an interactive boot menu at end of post.
@@ -165,5 +167,6 @@
#define DEBUG_ISR_hwpic1 5
#define DEBUG_ISR_hwpic2 5
#define DEBUG_HDL_pnp 1
+#define DEBUG_HDL_pmm 1
#endif // config.h
diff --git a/src/pmm.c b/src/pmm.c
new file mode 100644
index 0000000..bf53e3b
--- /dev/null
+++ b/src/pmm.c
@@ -0,0 +1,117 @@
+// Post memory manager (PMM) calls
+//
+// Copyright (C) 2009 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU LGPLv3 license.
+
+#include "util.h" // checksum
+#include "config.h" // BUILD_BIOS_ADDR
+
+struct pmmheader {
+ u32 signature;
+ u8 version;
+ u8 length;
+ u8 checksum;
+ u16 entry_offset;
+ u16 entry_seg;
+ u8 reserved[5];
+} PACKED;
+
+extern struct pmmheader PMMHEADER;
+
+#define PMM_SIGNATURE 0x4d4d5024 // $PMM
+
+#if CONFIG_PMM
+struct pmmheader PMMHEADER __aligned(16) VAR16EXPORT = {
+ .version = 0x01,
+ .length = sizeof(PMMHEADER),
+ .entry_seg = SEG_BIOS,
+};
+#endif
+
+#define FUNCTION_NOT_SUPPORTED 0xffffffff
+
+// PMM - allocate
+static u32
+handle_pmm00(u16 *args)
+{
+ u32 length = *(u32*)&args[1], handle = *(u32*)&args[3];
+ u16 flags = args[5];
+ dprintf(1, "pmm00: length=%x handle=%x flags=%x\n"
+ , length, handle, flags);
+ // XXX
+ return 0;
+}
+
+// PMM - find
+static u32
+handle_pmm01(u16 *args)
+{
+ u32 handle = *(u32*)&args[1];
+ dprintf(1, "pmm01: handle=%x\n", handle);
+ // XXX
+ return 0;
+}
+
+// PMM - deallocate
+static u32
+handle_pmm02(u16 *args)
+{
+ u32 buffer = *(u32*)&args[1];
+ dprintf(1, "pmm02: buffer=%x\n", buffer);
+ // XXX
+ return 0;
+}
+
+static u32
+handle_pmmXX(u16 *args)
+{
+ return FUNCTION_NOT_SUPPORTED;
+}
+
+u32 VISIBLE16
+handle_pmm(u16 *args)
+{
+ if (! CONFIG_PMM)
+ return FUNCTION_NOT_SUPPORTED;
+
+ u16 arg1 = args[0];
+ dprintf(DEBUG_HDL_pmm, "pmm call arg1=%x\n", arg1);
+
+ switch (arg1) {
+ case 0x00: return handle_pmm00(args);
+ case 0x01: return handle_pmm01(args);
+ case 0x02: return handle_pmm02(args);
+ default: return handle_pmmXX(args);
+ }
+}
+
+// romlayout.S
+extern void entry_pmm();
+
+void
+pmm_setup()
+{
+ if (! CONFIG_PMM)
+ return;
+
+ dprintf(3, "init PMM\n");
+
+ PMMHEADER.signature = PMM_SIGNATURE;
+ PMMHEADER.entry_offset = (u32)entry_pmm - BUILD_BIOS_ADDR;
+ PMMHEADER.checksum -= checksum(&PMMHEADER, sizeof(PMMHEADER));
+}
+
+void
+pmm_finalize()
+{
+ if (! CONFIG_PMM)
+ return;
+
+ dprintf(3, "finalize PMM\n");
+
+ PMMHEADER.signature = 0;
+ PMMHEADER.entry_offset = 0;
+
+ // XXX - zero low-memory allocations.
+}
diff --git a/src/post.c b/src/post.c
index 052edb5..9568ca4 100644
--- a/src/post.c
+++ b/src/post.c
@@ -167,6 +167,7 @@ post()
mtrr_setup();
smp_probe();
malloc_setup();
+ pmm_setup();
pnp_setup();
vga_setup();
@@ -180,8 +181,6 @@ post()
smm_init();
init_bios_tables();
- malloc_finalize();
- memmap_finalize();
boot_setup();
@@ -189,6 +188,10 @@ post()
hard_drive_setup();
optionrom_setup();
+
+ pmm_finalize();
+ malloc_finalize();
+ memmap_finalize();
}
// 32-bit entry point.
diff --git a/src/romlayout.S b/src/romlayout.S
index cbd9483..d430d28 100644
--- a/src/romlayout.S
+++ b/src/romlayout.S
@@ -270,6 +270,35 @@ entry_post:
* Misc. entry points.
****************************************************************/
+// PMM entry point
+ DECLFUNC entry_pmm
+entry_pmm:
+ pushl %esp // Backup %esp, then clear high bits
+ movzwl %sp, %esp
+ pushfl // Save registers clobbered by C code
+ cli
+ cld
+ pushl %eax
+ pushl %ecx
+ pushl %edx
+ pushw %es
+ pushw %ds
+ movw %ss, %cx // Move %ss to %ds
+ movw %cx, %ds
+ lea 28(%esp), %eax // %eax points to start of args
+ calll handle_pmm
+ movw %ax, 12(%esp) // Modify %ax:%dx to return %eax
+ shrl $16, %eax
+ movw %ax, 4(%esp)
+ popw %ds // Restore saved registers
+ popw %es
+ popl %edx
+ popl %ecx
+ popl %eax
+ popfl
+ popl %esp
+ lretw
+
// PnP entry points
DECLFUNC entry_pnp_real
.global entry_pnp_prot
@@ -281,6 +310,8 @@ entry_pnp_real:
movzwl %sp, %esp
1:
pushfl // Save registers clobbered by C code
+ cli
+ cld
pushl %eax
pushl %ecx
pushl %edx
diff --git a/src/util.h b/src/util.h
index 8ae54f4..8a43914 100644
--- a/src/util.h
+++ b/src/util.h
@@ -230,6 +230,10 @@ void init_dma();
u16 get_pnp_offset();
void pnp_setup();
+// pmm.c
+void pmm_setup();
+void pmm_finalize();
+
// mtrr.c
void mtrr_setup(void);