ref: b494f61baa98f9ebb17cae13257d056af995b9f3
parent: 983bd80477a6ed52cdf7f15191ef70bb5a6ac24e
parent: c612f9c41fd876c181f89472861245404cef65c5
author: cinap_lenrek <[email protected]>
date: Sat Jul 14 19:08:38 EDT 2012
merge
--- a/sys/src/9/pc/l.s
+++ b/sys/src/9/pc/l.s
@@ -46,11 +46,37 @@
LONG $_startKADDR-KZERO(SB) /* load_addr */
LONG $edata-KZERO(SB) /* load_end_addr */
LONG $end-KZERO(SB) /* bss_end_addr */
- LONG $_startKADDR-KZERO(SB) /* entry_addr */
+ LONG $_multibootentry-KZERO(SB) /* entry_addr */
LONG $0 /* mode_type */
LONG $0 /* width */
LONG $0 /* height */
LONG $0 /* depth */
+
+/*
+ * the kernel expects the data segment to be page-aligned
+ * multiboot bootloaders put the data segment right behind text
+ */
+TEXT _multibootentry(SB), $0
+ MOVL $etext-KZERO(SB), SI
+ MOVL SI, DI
+ ADDL $0xfff, DI
+ ANDL $~0xfff, DI
+ MOVL $edata-KZERO(SB), CX
+ SUBL DI, CX
+ ADDL CX, SI
+ ADDL CX, DI
+ STD
+ REP; MOVSB
+ CLD
+ ADDL $KZERO, BX
+ MOVL BX, multiboot-KZERO(SB)
+ MOVL $_startPADDR(SB), AX
+ ANDL $~KZERO, AX
+ JMP* AX
+
+/* multiboot structure pointer */
+TEXT multiboot(SB), $0
+ LONG $0
/*
* In protected mode with paging turned off and segment registers setup
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -37,6 +37,22 @@
{
long i, n;
char *cp, *line[MAXCONF], *p, *q;
+ ulong *m, l;
+ extern ulong *multiboot;
+
+ if(multiboot != nil){
+ cp = BOOTARGS;
+ *cp = 0;
+ if((*multiboot & 8) != 0 && multiboot[5] > 0){
+ m = KADDR(multiboot[6]);
+ l = m[1] - m[0];
+ m = KADDR(m[0]);
+ if(l >= BOOTARGSLEN)
+ l = BOOTARGSLEN - 1;
+ memmove(cp, m, l);
+ cp[l] = 0;
+ }
+ }
/*
* parse configuration args from dos file plan9.ini