[PATCH 3/9] Linux loader: integrate lilo.c to Hatari and add --lilo option

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


There are few bugs:

* Hatari itself doesn't have yet good enough Falcon support for Linux
  (booting works on real devices, but not in Hatari)

* Disassembly and memdump show just zero memory content for the
  executed instructions after Linux has been started
---
 src/CMakeLists.txt           |  2 +-
 src/configuration.c          | 30 ++++++++++++++++++++++++++++++
 src/includes/configuration.h | 12 ++++++++++++
 src/options.c                | 27 ++++++++++++++++++++++++++-
 src/tos.c                    | 11 +++++++++--
 5 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fe9567b7..c941d829 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,7 +9,7 @@ set(SOURCES
 	ncr5380.c paths.c  psg.c printer.c resolution.c rs232.c reset.c rtc.c
 	scandir.c scc.c stMemory.c screen.c screenConvert.c screenSnapShot.c
 	shortcut.c sound.c spec512.c statusbar.c str.c tos.c utils.c
-	vdi.c inffile.c video.c wavFormat.c xbios.c ymFormat.c)
+	vdi.c inffile.c video.c wavFormat.c xbios.c ymFormat.c lilo.c)
 
 # Disk image code is shared with the hmsa tool, so we put it into a library:
 add_library(Floppy createBlankImage.c dim.c msa.c st.c zip.c)
diff --git a/src/configuration.c b/src/configuration.c
index d781ca2d..d3ce9504 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -540,6 +540,17 @@ static const struct Config_Tag configs_Rom[] =
 	{ NULL , Error_Tag, NULL }
 };
 
+/* Used to load/save LILO options, names are same as with Aranym */
+static const struct Config_Tag configs_Lilo[] =
+{
+	{ "Args", String_Tag, ConfigureParams.Lilo.szCommandLine },
+	{ "Kernel", String_Tag, ConfigureParams.Lilo.szKernelFileName },
+	{ "Ramdisk", String_Tag, ConfigureParams.Lilo.szRamdiskFileName },
+	{ "HaltOnReboot", Bool_Tag, &ConfigureParams.Lilo.bHaltOnReboot },
+	{ "LoadToFastRam", Bool_Tag, &ConfigureParams.Lilo.bLoadFastRam },
+	{ NULL , Error_Tag, NULL }
+};
+
 /* Used to load/save RS232 options */
 static const struct Config_Tag configs_Rs232[] =
 {
@@ -846,6 +857,16 @@ void Configuration_SetDefault(void)
 	ConfigureParams.Rom.bPatchTos = true;
 	strcpy(ConfigureParams.Rom.szCartridgeImageFileName, "");
 
+	/* Set defaults for Lilo */
+	strcpy(ConfigureParams.Lilo.szCommandLine,
+	       "root=/dev/ram video=atafb:vga16 load_ramdisk=1");
+	sprintf(ConfigureParams.Lilo.szKernelFileName,
+		"%s%cvmlinuz", Paths_GetDataDir(), PATHSEP);
+	sprintf(ConfigureParams.Lilo.szRamdiskFileName,
+		"%s%cinitrd", Paths_GetDataDir(), PATHSEP);
+	ConfigureParams.Lilo.bHaltOnReboot = true;
+	ConfigureParams.Lilo.bLoadFastRam = true;
+
 	/* Set defaults for System */
 	ConfigureParams.System.nMachineType = MACHINE_ST;
 	ConfigureParams.System.nCpuLevel = 0;
@@ -976,6 +997,10 @@ void Configuration_Apply(bool bReset)
 	File_MakeAbsoluteName(ConfigureParams.Rom.szTosImageFileName);
 	if (strlen(ConfigureParams.Rom.szCartridgeImageFileName) > 0)
 		File_MakeAbsoluteName(ConfigureParams.Rom.szCartridgeImageFileName);
+	if (strlen(ConfigureParams.Lilo.szKernelFileName) > 0)
+		File_MakeAbsoluteName(ConfigureParams.Lilo.szKernelFileName);
+	if (strlen(ConfigureParams.Lilo.szRamdiskFileName) > 0)
+		File_MakeAbsoluteName(ConfigureParams.Lilo.szRamdiskFileName);
 	File_CleanFileName(ConfigureParams.HardDisk.szHardDiskDirectories[0]);
 	File_MakeAbsoluteName(ConfigureParams.HardDisk.szHardDiskDirectories[0]);
 	File_MakeAbsoluteName(ConfigureParams.Memory.szMemoryCaptureFileName);
@@ -1123,6 +1148,7 @@ void Configuration_Load(const char *psFileName)
 	Configuration_LoadSection(psFileName, configs_Scsi, "[SCSI]");
 	Configuration_LoadSection(psFileName, configs_Ide, "[IDE]");
 	Configuration_LoadSection(psFileName, configs_Rom, "[ROM]");
+	Configuration_LoadSection(psFileName, configs_Lilo, "[LILO]");
 	Configuration_LoadSection(psFileName, configs_Rs232, "[RS232]");
 	Configuration_LoadSection(psFileName, configs_Printer, "[Printer]");
 	Configuration_LoadSection(psFileName, configs_Midi, "[Midi]");
@@ -1179,6 +1205,7 @@ void Configuration_Save(void)
 	Configuration_SaveSection(sConfigFileName, configs_Scsi, "[SCSI]");
 	Configuration_SaveSection(sConfigFileName, configs_Ide, "[IDE]");
 	Configuration_SaveSection(sConfigFileName, configs_Rom, "[ROM]");
+	Configuration_SaveSection(sConfigFileName, configs_Lilo, "[LILO]");
 	Configuration_SaveSection(sConfigFileName, configs_Rs232, "[RS232]");
 	Configuration_SaveSection(sConfigFileName, configs_Printer, "[Printer]");
 	Configuration_SaveSection(sConfigFileName, configs_Midi, "[Midi]");
@@ -1199,6 +1226,9 @@ void Configuration_MemorySnapShot_Capture(bool bSave)
 	MemorySnapShot_Store(ConfigureParams.Rom.szTosImageFileName, sizeof(ConfigureParams.Rom.szTosImageFileName));
 	MemorySnapShot_Store(ConfigureParams.Rom.szCartridgeImageFileName, sizeof(ConfigureParams.Rom.szCartridgeImageFileName));
 
+	MemorySnapShot_Store(ConfigureParams.Lilo.szKernelFileName, sizeof(ConfigureParams.Lilo.szKernelFileName));
+	MemorySnapShot_Store(ConfigureParams.Lilo.szRamdiskFileName, sizeof(ConfigureParams.Lilo.szRamdiskFileName));
+
 	MemorySnapShot_Store(&ConfigureParams.Memory.STRamSize_KB, sizeof(ConfigureParams.Memory.STRamSize_KB));
 	MemorySnapShot_Store(&ConfigureParams.Memory.TTRamSize_KB, sizeof(ConfigureParams.Memory.TTRamSize_KB));
 
diff --git a/src/includes/configuration.h b/src/includes/configuration.h
index b83575e3..b0b43036 100644
--- a/src/includes/configuration.h
+++ b/src/includes/configuration.h
@@ -50,6 +50,17 @@ typedef struct
 } CNF_ROM;
 
 
+/* LILO (Linux loader) configuration */
+typedef struct
+{
+  char szCommandLine[256];	/* bootinfo CL_SIZE */
+  char szKernelFileName[FILENAME_MAX];
+  char szRamdiskFileName[FILENAME_MAX];
+  bool bHaltOnReboot;
+  bool bLoadFastRam;
+} CNF_LILO;
+
+
 /* Sound configuration */
 typedef struct
 {
@@ -410,6 +421,7 @@ typedef struct
   CNF_SCSIDEV Scsi[MAX_SCSI_DEVS];
   CNF_IDEDEV Ide[MAX_IDE_DEVS];
   CNF_ROM Rom;
+  CNF_LILO Lilo;
   CNF_RS232 RS232;
   CNF_PRINTER Printer;
   CNF_MIDI Midi;
diff --git a/src/options.c b/src/options.c
index 2a4d8dc3..ae8ac4bb 100644
--- a/src/options.c
+++ b/src/options.c
@@ -44,6 +44,7 @@ const char Options_fileid[] = "Hatari options.c : " __DATE__ " " __TIME__;
 #include "xbios.h"
 #include "stMemory.h"
 #include "tos.h"
+#include "lilo.h"
 
 
 bool bLoadAutoSave;        /* Load autosave memory snapshot at startup */
@@ -172,6 +173,9 @@ enum {
 #endif
 	OPT_DEBUG,
 	OPT_EXCEPTIONS,
+#if ENABLE_WINUAE_CPU
+	OPT_LILO,
+#endif
 	OPT_BIOSINTERCEPT,
 	OPT_CONOUT,
 	OPT_DISASM,
@@ -458,6 +462,9 @@ static const opt_t HatariOptions[] = {
 	  NULL, "Toggle whether CPU exceptions invoke debugger" },
 	{ OPT_EXCEPTIONS, NULL, "--debug-except",
 	  "<flags>", "Exceptions invoking debugger, see '--debug-except help'" },
+#if ENABLE_WINUAE_CPU
+	{ OPT_LILO, NULL, "--lilo", "<x>", "Boot Linux (see manual page)" },
+#endif
 	{ OPT_BIOSINTERCEPT, NULL, "--bios-intercept",
 	  "<bool>", "Enable/disable XBIOS command parsing support" },
 	{ OPT_CONOUT,   NULL, "--conout",
@@ -1037,6 +1044,7 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
 	int ncpu, skips, zoom, planes, cpuclock, threshold, memsize, port, freq, temp, drive;
 	const char *errstr, *str;
 	int i, ok = true;
+	size_t len;
 	int val;
 
 	/* Defaults for loading initial memory snap-shots */
@@ -2073,7 +2081,24 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
 				        oldmask, ExceptionDebugMask);
 			}
 			break;
-
+#if ENABLE_WINUAE_CPU
+		case OPT_LILO:
+			len = strlen(argv[++i]);
+			len += strlen(ConfigureParams.Lilo.szCommandLine);
+			if (argv[i][0] && len+2 < sizeof(ConfigureParams.Lilo.szCommandLine))
+			{
+				strcat(ConfigureParams.Lilo.szCommandLine, " ");
+				strcat(ConfigureParams.Lilo.szCommandLine, argv[i]);
+				bLoadAutoSave = false;
+				bUseLilo = true;
+				bUseTos = false;
+			}
+			else
+			{
+				return Opt_ShowError(OPT_LILO, argv[i], "kernel command line too long");
+			}
+			break;
+#endif
 		case OPT_BIOSINTERCEPT:
 			ok = Opt_Bool(argv[++i], OPT_BIOSINTERCEPT, &bBiosIntercept);
 			Log_Printf(LOG_DEBUG, "XBIOS 11/20/255 Hatari versions %sabled: "
diff --git a/src/tos.c b/src/tos.c
index a310a34b..2746a722 100644
--- a/src/tos.c
+++ b/src/tos.c
@@ -32,6 +32,7 @@ const char TOS_fileid[] = "Hatari tos.c : " __DATE__ " " __TIME__;
 #include "stMemory.h"
 #include "str.h"
 #include "tos.h"
+#include "lilo.h"
 #include "vdi.h"
 #include "falcon/dsp.h"
 #include "clocks_timings.h"
@@ -1189,9 +1190,15 @@ int TOS_InitImage(void)
 	/* Set connected devices, memory configuration, etc. */
 	STMemory_SetDefaultConfig();
 
-	/* Load test program (has to be done after memory has been cleared */
-	if (!bUseTos)
+	if (bUseLilo)
 	{
+		/* load linux */
+		if (!lilo_init())
+			return -1;
+	}
+	else if (!bUseTos)
+	{
+		/* Load test program (has to be done after memory has been cleared) */
 		if (psTestPrg)
 		{
 			Log_Printf(LOG_DEBUG, "Loading '%s' to 0x%x.\n",
-- 
2.11.0


--------------A9B4B3CBBE16AB6BBACAF517
Content-Type: text/x-patch;
 name="0002-Linux-loader-adapt-lilo.c-Aranym-code-to-Hatari.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0002-Linux-loader-adapt-lilo.c-Aranym-code-to-Hatari.patch"



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/