Skip to contentSkip to conversation

Module rewrite 7/20: Boot and module PARAM unification

PATCH New Rusty Russell 1 participant 1 message Sep 25, 2002 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Module rewrite 7/20: Boot and module PARAM unification

Name: Parameter Core Patch
Author: Rusty Russell
Status: Tested on 2.5.38
Depends: Misc/strcspn.patch.gz
Depends: Misc/bigrefs.patch.gz
Depends: Misc/streq.patch.gz

D: This patch is a rewrite of the insmod and boot parameter handling,
D: to unify them. It only contains the core of the infrastructure,
D: and the conversion main boot parameters: all other boot parameters
D: will no longer work with this change (although stubs are in place
D: to let them compile).
D:
D: The new format is fairly simple: built on top of __PARAM_CALL there
D: are several helpers, eg "PARAM(foo, int, 000)". The final argument
D: is the permissions bits, for exposing parameters in driverfs (if
D: non-zero) at a later stage.

include/asm-i386/setup.h +19 -19
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .19230-linux-2.5.38/include/asm-i386/setup.h .19230-linux-2.5.38.updated/include/asm-i386/setup.h
@@ -19,25 +19,25 @@
 /*
  * This is set up by the setup-routine at boot-time
  */
-#define PARAM	((unsigned char *)empty_zero_page)
-#define SCREEN_INFO (*(struct screen_info *) (PARAM+0))
-#define EXT_MEM_K (*(unsigned short *) (PARAM+2))
-#define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0))
-#define E820_MAP_NR (*(char*) (PARAM+E820NR))
-#define E820_MAP    ((struct e820entry *) (PARAM+E820MAP))
-#define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40))
-#define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))
-#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0))
-#define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))
-#define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8))
-#define VIDEO_MODE (*(unsigned short *) (PARAM+0x1FA))
-#define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))
-#define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
-#define LOADER_TYPE (*(unsigned char *) (PARAM+0x210))
-#define KERNEL_START (*(unsigned long *) (PARAM+0x214))
-#define INITRD_START (*(unsigned long *) (PARAM+0x218))
-#define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))
-#define COMMAND_LINE ((char *) (PARAM+2048))
+#define PARAMS	((unsigned char *)empty_zero_page)
+#define SCREEN_INFO (*(struct screen_info *) (PARAMS+0))
+#define EXT_MEM_K (*(unsigned short *) (PARAMS+2))
+#define ALT_MEM_K (*(unsigned long *) (PARAMS+0x1e0))
+#define E820_MAP_NR (*(char*) (PARAMS+E820NR))
+#define E820_MAP    ((struct e820entry *) (PARAMS+E820MAP))
+#define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAMS+0x40))
+#define DRIVE_INFO (*(struct drive_info_struct *) (PARAMS+0x80))
+#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAMS+0xa0))
+#define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAMS+0x1F2))
+#define RAMDISK_FLAGS (*(unsigned short *) (PARAMS+0x1F8))
+#define VIDEO_MODE (*(unsigned short *) (PARAMS+0x1FA))
+#define ORIG_ROOT_DEV (*(unsigned short *) (PARAMS+0x1FC))
+#define AUX_DEVICE_INFO (*(unsigned char *) (PARAMS+0x1FF))
+#define LOADER_TYPE (*(unsigned char *) (PARAMS+0x210))
+#define KERNEL_START (*(unsigned long *) (PARAMS+0x214))
+#define INITRD_START (*(unsigned long *) (PARAMS+0x218))
+#define INITRD_SIZE (*(unsigned long *) (PARAMS+0x21c))
+#define COMMAND_LINE ((char *) (PARAMS+2048))
 #define COMMAND_LINE_SIZE 256
 
 #endif /* _i386_SETUP_H */
include/linux/init.h +10 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .19230-linux-2.5.38/include/linux/init.h .19230-linux-2.5.38.updated/include/linux/init.h
@@ -172,6 +172,16 @@ typedef void (*__cleanup_module_func_t)(
 /* Data marked not to be saved by software_suspend() */
 #define __nosavedata __attribute__ ((__section__ (".data.nosave")))
 
+/* This means "can be init if no module support, otherwise module load
+   may call it." */
+#ifdef CONFIG_MODULES
+#define __init_or_module
+#define __initdata_or_module
+#else
+#define __init_or_module __init
+#define __initdata_or_module __initdata
+#endif /*CONFIG_MODULES*/
+
 #ifdef CONFIG_HOTPLUG
 #define __devinit
 #define __devinitdata
include/linux/kernel.h +2 -2
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .19230-linux-2.5.38/include/linux/kernel.h .19230-linux-2.5.38.updated/include/linux/kernel.h
@@ -63,8 +63,8 @@ extern int sscanf(const char *, const ch
 	__attribute__ ((format (scanf,2,3)));
 extern int vsscanf(const char *, const char *, va_list);
 
-extern int get_option(char **str, int *pint);
-extern char *get_options(char *str, int nints, int *ints);
+extern int get_option(const char **str, int *pint);
+extern char *get_options(const char *str, int nints, int *ints);
 extern unsigned long long memparse(char *ptr, char **retptr);
 extern void dev_probe_lock(void);
 extern void dev_probe_unlock(void);
include/linux/params.h +123 -0

123 lines not on this page · raw message

init/main.c +30 -62

117 lines not on this page · raw message

kernel/Makefile +3 -2
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .19230-linux-2.5.38/kernel/Makefile .19230-linux-2.5.38.updated/kernel/Makefile
@@ -2,13 +2,14 @@
 # Makefile for the linux kernel.
 #
 
-export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o \
+export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o params.o \
 		printk.o platform.o suspend.o dma.o bigref.o
 
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    module.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
-	    signal.o sys.o kmod.o context.o futex.o platform.o pid.o bigref.o
+	    signal.o sys.o kmod.o context.o futex.o platform.o pid.o bigref.o \
+	    params.o
 
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
 obj-$(CONFIG_SMP) += cpu.o
kernel/params.c +338 -0

338 lines not on this page · raw message

lib/cmdline.c +5 -5
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .19230-linux-2.5.38/lib/cmdline.c .19230-linux-2.5.38.updated/lib/cmdline.c
@@ -31,13 +31,13 @@
  *	2 : int found including a subsequent comma
  */
 
-int get_option (char **str, int *pint)
+int get_option (const char **str, int *pint)
 {
-	char *cur = *str;
+	const char *cur = *str;
 
 	if (!cur || !(*cur))
 		return 0;
-	*pint = simple_strtol (cur, str, 0);
+	*pint = simple_strtol (cur, (char **)str, 0);
 	if (cur == *str)
 		return 0;
 	if (**str == ',') {
@@ -64,7 +64,7 @@ int get_option (char **str, int *pint)
  *	completely parseable).
  */
  
-char *get_options (char *str, int nints, int *ints)
+char *get_options (const char *str, int nints, int *ints)
 {
 	int res, i = 1;
 
@@ -77,7 +77,7 @@ char *get_options (char *str, int nints,
 			break;
 	}
 	ints[0] = i - 1;
-	return (str);
+	return (char *)str;
 }
 
 /**

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.