xref: /plan9/sys/src/9/pcboot/multiboot.c (revision 25210b069a6ed8c047fa67220cf1dff32812f121)
1 #include	"u.h"
2 #include	"../port/lib.h"
3 #include	"mem.h"
4 #include	"dat.h"
5 #include	"fns.h"
6 #include	"io.h"
7 #include	"ureg.h"
8 
9 Mbi	mbhdr;
10 int	nmmap;
11 
12 /* these need to end up in low memory */
13 Mbi	*multibootheader = &mbhdr;
14 MMap	mmap[32+1];
15 
16 void
mkmultiboot(void)17 mkmultiboot(void)
18 {
19 	MMap *lmmap;
20 
21 	/* reuse the bios table memory */
22 	multibootheader = (Mbi *)KADDR(BIOSTABLES);
23 	memset(multibootheader, 0, sizeof *multibootheader);
24 
25 	lmmap = (MMap *)(multibootheader + 1);
26 	memmove(lmmap, mmap, sizeof mmap);
27 
28 	multibootheader->cmdline = PADDR(BOOTLINE);
29 	multibootheader->flags |= Fcmdline;
30 	if(nmmap != 0){
31 		multibootheader->mmapaddr = PADDR(lmmap);
32 		multibootheader->mmaplength = nmmap*sizeof(MMap);
33 		multibootheader->flags |= Fmmap;
34 	}
35 	multibootheader = (Mbi *)PADDR(multibootheader);
36 	if(v_flag)
37 		print("PADDR(&multibootheader) %#p\n", multibootheader);
38 }
39