RAMDISK-boot-patch †
- RAMDISKについて
- 通常の仕様 … (間違っているかも)
- RAMDISKイメージは、mdsetimageで、カーネル内のデータセクションに配置される。
- データセクションには、RAMDISKを格納できるだけの十分な容量が必要
- 本容量はビルド時に設定されるものであり、後から変更不可能?
- 専用ブートローダでロードするための苦肉の策的実装か?
- hpcshアーキテクチャでのRAMDISK仕様
- RAMDISKイメージは、カーネル外にあることを想定している。
- 従って、カーネルは、RAMDISKの配置場所を知る手段が必要。
- 暗黙ルール?、カーネルエンド+(シンボルテーブル)+ページ境界に配置されるらしい。
- RAMDISKのサイズは、カーネル起動時に動的に決定されるらしい。
- カーネルとRAMDISKが完全分離する本仕様は、運用面において柔軟性に富む?。
- ただし、専用ブートローダが必要。kernelsw-3.2 or kexec にて対応。
- RAMDISKブートパッチ
hpcshからコードを拝借したので後者の仕様になっています。
(亜流のブートローダが必要なので、メインラインにマージされることはないでしょう。)
diff -urN sys/arch/landisk.orig/conf/RAMDISK sys/arch/landisk/conf/RAMDISK
--- sys/arch/landisk.orig/conf/RAMDISK 1970-01-01 09:00:00.000000000 +0900
+++ sys/arch/landisk/conf/RAMDISK 2005-08-31 21:12:41.000000000 +0900
@@ -0,0 +1,19 @@
+#
+# kernel config file for memory(RAM) disk
+#
+# $NetBSD: RAMDISK,v 1.4 2002/05/09 12:39:24 uch Exp $
+#
+
+include "arch/landisk/conf/GENERIC"
+
+# disk/mass storage pseudo-devices
+# pseudo-device md 1 # memory disk device (ramdisk)
+
+# Enable the hooks used for initializing the root memory-disk.
+options MEMORY_DISK_HOOKS
+options MEMORY_DISK_IS_ROOT # force root on memory disk
+options MEMORY_DISK_SERVER=0 # no userspace memory disk support
+options MEMORY_DISK_DYNAMIC # fs image don't exist in data section.
+#options MEMORY_DISK_ROOT_SIZE=8192 # 4MB size of memory disk, in blocks
+options MEMORY_DISK_ROOT_SIZE=16384 # 8MB size of memory disk, in blocksoptions
+options MEMORY_RBFLAGS=0
diff -urN sys/arch/landisk.orig/landisk/machdep.c sys/arch/landisk/landisk/machdep.c
--- sys/arch/landisk.orig/landisk/machdep.c 2005-08-28 13:04:13.000000000 +0900
+++ sys/arch/landisk/landisk/machdep.c 2005-09-01 21:35:00.000000000 +0900
@@ -93,6 +93,7 @@
#include <sys/ksyms.h>
#include <uvm/uvm_extern.h>
+#include <ufs/mfs/mfs_extern.h> /* mfs_initminiroot() */
#include <dev/cons.h>
@@ -163,6 +164,22 @@
{
extern char edata[], end[];
vaddr_t kernend;
+ size_t symbolsize;
+ int i;
+
+ /* Symbol table size */
+ symbolsize = 0;
+ if (memcmp(&end, ELFMAG, SELFMAG) == 0) {
+ Elf_Ehdr *eh = (void *)end;
+ Elf_Shdr *sh = (void *)(end + eh->e_shoff);
+ for(i = 0; i < eh->e_shnum; i++, sh++)
+ if (sh->sh_offset > 0 &&
+ (sh->sh_offset + sh->sh_size) > symbolsize)
+ symbolsize = sh->sh_offset + sh->sh_size;
+ }
+
+ /* Start to determine heap area */
+ kernend = (vaddr_t)sh3_round_page(end + symbolsize);
/* Clear bss */
memset(edata, 0, end - edata);
@@ -182,6 +199,20 @@
/* Initialize console */
consinit();
+ /*
+ * Check to see if a mini-root was loaded into memory. It resides
+ * at the start of the next page just after the end of BSS.
+ */
+ if (boothowto & RB_MINIROOT) {
+ size_t fssz;
+ fssz = sh3_round_page(mfs_initminiroot( (void *)kernend));
+#ifdef MEMORY_DISK_DYNAMIC
+ md_root_setconf((caddr_t)kernend, fssz);
+ printf("enter MEMORY_DISK_DYNAMIC");
+#endif
+ kernend += fssz;
+ }
+
#ifdef KLOADER
/* copy boot parameter for kloader */
kloader_bootinfo_set(&kbootinfo, 0, NULL, NULL, TRUE);
@@ -189,7 +220,7 @@
/* Load memory to UVM */
physmem = atop(IOM_RAM_SIZE);
- kernend = atop(round_page(SH3_P1SEG_TO_PHYS(end)));
+ kernend = atop(round_page(SH3_P1SEG_TO_PHYS(kernend)));
uvm_page_physload(
physmem, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
@@ -203,7 +234,10 @@
/* Debugger. */
#if NKSYMS || defined(DDB) || defined(LKM)
- ksyms_init(0, NULL, NULL);
+ // ksyms_init(0, NULL, NULL);
+ if (symbolsize) {
+ ksyms_init(symbolsize, &end, end + symbolsize);
+ }
#endif
#if defined(DDB)
if (boothowto & RB_KDB) {
@@ -311,7 +345,8 @@
haltsys:
doshutdownhooks();
- if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
+ // if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
+ if (howto & RB_POWERDOWN) {
_reg_write_1(LANDISK_PWRMNG, PWRMNG_POWEROFF);
delay(1 * 1000 * 1000);
printf("POWEROFF FAILED!\n");
@@ -321,7 +356,7 @@
printf("\n");
printf("The operating system has halted.\n");
printf("Please press any key to reboot.\n\n");
- cngetc();
+ // cngetc();
}
#ifdef KLOADER
else {
|