linux-3.9-mykernel环境搭建

linux-3.9环境搭建参考这里搭建。
增加报错时的解决方案。

1 linux环境搭建步骤

1.1 安装qemu

  • sudo apt-get install qemu
  • sudo ln -s /usr/bin/qemu-system-i386 /usr/bin/qemu

1.2 下载linux源码

  • wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.9.4.tar.xz
    linux-3.9.4不一定能下载出来这里是另一个下载链接linux-3.9.3.tar.xz

1.3 下载mykernel,patch

  • wget https://raw.github.com/mengning/mykernel/master/mykernel_for_linux3.9.4sc.patch
    这个也不一定能下载出来,下面是patch源码
diff -Naur linux-3.9.4/arch/x86/kernel/time.c linux-3.9.4.new/arch/x86/kernel/time.c
--- linux-3.9.4/arch/x86/kernel/time.c	2013-05-24 11:45:59.000000000 -0700
+++ linux-3.9.4.new/arch/x86/kernel/time.c	2013-06-25 21:39:34.641299852 -0700
@@ -13,6 +13,7 @@
 #include <linux/interrupt.h>
 #include <linux/i8253.h>
 #include <linux/time.h>
+#include <linux/timer.h>
 #include <linux/export.h>
 
 #include <asm/vsyscall.h>
@@ -57,6 +58,7 @@
 static irqreturn_t timer_interrupt(int irq, void *dev_id)
 {
 	global_clock_event->event_handler(global_clock_event);
+    my_timer_handler();
 	return IRQ_HANDLED;
 }
 
@@ -68,6 +70,7 @@
 
 void __init setup_default_timer_irq(void)
 {
+    printk(KERN_NOTICE "timer interrupt setup\n"); 
 	setup_irq(0, &irq0);
 }
 
diff -Naur linux-3.9.4/include/linux/start_kernel.h linux-3.9.4.new/include/linux/start_kernel.h
--- linux-3.9.4/include/linux/start_kernel.h	2013-05-24 11:45:59.000000000 -0700
+++ linux-3.9.4.new/include/linux/start_kernel.h	2013-06-25 19:18:58.396722448 -0700
@@ -8,5 +8,6 @@
    up something else. */
 
 extern asmlinkage void __init start_kernel(void);
+extern void __init my_start_kernel(void);
 
 #endif /* _LINUX_START_KERNEL_H */
diff -Naur linux-3.9.4/include/linux/timer.h linux-3.9.4.new/include/linux/timer.h
--- linux-3.9.4/include/linux/timer.h	2013-05-24 11:45:59.000000000 -0700
+++ linux-3.9.4.new/include/linux/timer.h	2013-06-25 21:28:37.609026644 -0700
@@ -251,6 +251,8 @@
 
 extern void init_timers(void);
 extern void run_local_timers(void);
+extern void my_timer_handler(void);
+
 struct hrtimer;
 extern enum hrtimer_restart it_real_fn(struct hrtimer *);
 
diff -Naur linux-3.9.4/init/main.c linux-3.9.4.new/init/main.c
--- linux-3.9.4/init/main.c	2013-05-24 11:45:59.000000000 -0700
+++ linux-3.9.4.new/init/main.c	2013-06-25 20:16:17.452763103 -0700
@@ -574,7 +574,6 @@
 	console_init();
 	if (panic_later)
 		panic(panic_later, panic_param);
-
 	lockdep_info();
 
 	/*
@@ -641,6 +640,7 @@
 
 	ftrace_init();
 
+    my_start_kernel();
 	/* Do the rest non-__init'ed, we're now alive */
 	rest_init();
 }
diff -Naur linux-3.9.4/Makefile linux-3.9.4.new/Makefile
--- linux-3.9.4/Makefile	2013-05-24 11:45:59.000000000 -0700
+++ linux-3.9.4.new/Makefile	2013-06-25 19:16:00.177364039 -0700
@@ -733,7 +733,7 @@
 
 
 ifeq ($(KBUILD_EXTMOD),)
-core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/
+core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/ mykernel/
 
 vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
diff -Naur linux-3.9.4/mykernel/Makefile linux-3.9.4.new/mykernel/Makefile
--- linux-3.9.4/mykernel/Makefile	1969-12-31 16:00:00.000000000 -0800
+++ linux-3.9.4.new/mykernel/Makefile	2013-06-25 21:40:24.174030881 -0700
@@ -0,0 +1,6 @@
+#
+# Makefile for the linux mykernel.
+#
+
+obj-y     = mymain.o myinterrupt.o
+
diff -Naur linux-3.9.4/mykernel/myinterrupt.c linux-3.9.4.new/mykernel/myinterrupt.c
--- linux-3.9.4/mykernel/myinterrupt.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-3.9.4.new/mykernel/myinterrupt.c	2013-06-25 21:45:38.408915841 -0700
@@ -0,0 +1,47 @@
+/*
+ *  linux/mykernel/myinterrupt.c
+ *
+ *  Kernel internal my_timer_handler
+ *
+ *  Copyright (C) 2013  Mengning
+ *
+ */
+#include <linux/kernel_stat.h>
+#include <linux/export.h>
+#include <linux/interrupt.h>
+#include <linux/percpu.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/pid_namespace.h>
+#include <linux/notifier.h>
+#include <linux/thread_info.h>
+#include <linux/time.h>
+#include <linux/jiffies.h>
+#include <linux/posix-timers.h>
+#include <linux/cpu.h>
+#include <linux/syscalls.h>
+#include <linux/delay.h>
+#include <linux/tick.h>
+#include <linux/kallsyms.h>
+#include <linux/irq_work.h>
+#include <linux/sched.h>
+#include <linux/sched/sysctl.h>
+#include <linux/slab.h>
+
+#include <asm/uaccess.h>
+#include <asm/unistd.h>
+#include <asm/div64.h>
+#include <asm/timex.h>
+#include <asm/io.h>
+
+#define CREATE_TRACE_POINTS
+#include <trace/events/timer.h>
+
+/*
+ * Called by timer interrupt.
+ */
+void my_timer_handler(void)
+{
+	printk(KERN_NOTICE "\n>>>>>>>>>>>>>>>>>my_timer_handler here<<<<<<<<<<<<<<<<<<\n\n");
+}
diff -Naur linux-3.9.4/mykernel/mymain.c linux-3.9.4.new/mykernel/mymain.c
--- linux-3.9.4/mykernel/mymain.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-3.9.4.new/mykernel/mymain.c	2013-06-25 21:44:59.489317439 -0700
@@ -0,0 +1,93 @@
+/*
+ *  linux/mykernel/mymain.c
+ *
+ *  Kernel internal my_start_kernel
+ *
+ *  Copyright (C) 2013  Mengning
+ *
+ */
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/kernel.h>
+#include <linux/syscalls.h>
+#include <linux/stackprotector.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/initrd.h>
+#include <linux/bootmem.h>
+#include <linux/acpi.h>
+#include <linux/tty.h>
+#include <linux/percpu.h>
+#include <linux/kmod.h>
+#include <linux/vmalloc.h>
+#include <linux/kernel_stat.h>
+#include <linux/start_kernel.h>
+#include <linux/security.h>
+#include <linux/smp.h>
+#include <linux/profile.h>
+#include <linux/rcupdate.h>
+#include <linux/moduleparam.h>
+#include <linux/kallsyms.h>
+#include <linux/writeback.h>
+#include <linux/cpu.h>
+#include <linux/cpuset.h>
+#include <linux/cgroup.h>
+#include <linux/efi.h>
+#include <linux/tick.h>
+#include <linux/interrupt.h>
+#include <linux/taskstats_kern.h>
+#include <linux/delayacct.h>
+#include <linux/unistd.h>
+#include <linux/rmap.h>
+#include <linux/mempolicy.h>
+#include <linux/key.h>
+#include <linux/buffer_head.h>
+#include <linux/page_cgroup.h>
+#include <linux/debug_locks.h>
+#include <linux/debugobjects.h>
+#include <linux/lockdep.h>
+#include <linux/kmemleak.h>
+#include <linux/pid_namespace.h>
+#include <linux/device.h>
+#include <linux/kthread.h>
+#include <linux/sched.h>
+#include <linux/signal.h>
+#include <linux/idr.h>
+#include <linux/kgdb.h>
+#include <linux/ftrace.h>
+#include <linux/async.h>
+#include <linux/kmemcheck.h>
+#include <linux/sfi.h>
+#include <linux/shmem_fs.h>
+#include <linux/slab.h>
+#include <linux/perf_event.h>
+#include <linux/file.h>
+#include <linux/ptrace.h>
+#include <linux/blkdev.h>
+#include <linux/elevator.h>
+
+#include <asm/io.h>
+#include <asm/bugs.h>
+#include <asm/setup.h>
+#include <asm/sections.h>
+#include <asm/cacheflush.h>
+
+#ifdef CONFIG_X86_LOCAL_APIC
+#include <asm/smp.h>
+#endif
+
+void __init my_start_kernel(void)
+{
+    int i = 0;
+    while(1)
+    {
+        i++;
+        if(i%100000 == 0)
+            printk(KERN_NOTICE "my_start_kernel here  %d \n",i);
+            
+    }
+}
diff -Naur linux-3.9.4/mykernel/README.md linux-3.9.4.new/mykernel/README.md
--- linux-3.9.4/mykernel/README.md	1969-12-31 16:00:00.000000000 -0800
+++ linux-3.9.4.new/mykernel/README.md	2013-06-25 21:52:52.467808733 -0700
@@ -0,0 +1,3 @@
+mykernel
+==========
+It is a platform to write your own OS kernel,its based on Linux Kernel 3.9.4 source code.

1.4 支持git的话可以用下面这个patch

From 37287bc91178ff0b73ec9a8edeba92f34784be87 Mon Sep 17 00:00:00 2001
From: weidonghui <weidonghui@allwinnertech.com>
Date: Mon, 11 May 2020 22:38:41 +0800
Subject: [PATCH] linux3.9:support my kernel
To: shuge <shuge@allwinnertech.com>
Cc: kevin <kevin@allwinnertech.com>,
    sunny <sunny@allwinnertech.com>,
    leafy <leafy.myeh@allwinnertech.com>,
    liugang <liugang@allwinnertech.com>,
    others

Signed-off-by: weidonghui <weidonghui@allwinnertech.com>
---
 Makefile                      |  2 +-
 arch/x86/kernel/time.c        |  3 ++
 include/linux/compiler-gcc5.h | 68 +++++++++++++++++++++++++++++++
 include/linux/start_kernel.h  |  1 +
 include/linux/timer.h         |  2 +
 init/main.c                   |  2 +-
 mykernel/Makefile             |  6 +++
 mykernel/myinterrupt.c        | 47 ++++++++++++++++++++++
 mykernel/mymain.c             | 93 +++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 222 insertions(+), 2 deletions(-)
 create mode 100644 include/linux/compiler-gcc5.h
 create mode 100644 mykernel/Makefile
 create mode 100644 mykernel/myinterrupt.c
 create mode 100644 mykernel/mymain.c

diff --git a/Makefile b/Makefile
index bfbfaf9..cead503 100644
--- a/Makefile
+++ b/Makefile
@@ -733,7 +733,7 @@ export mod_sign_cmd
 
 
 ifeq ($(KBUILD_EXTMOD),)
-core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/
+core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/ mykernel/
 
 vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
index 24d3c91..0e52a56 100644
--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -13,6 +13,7 @@
 #include <linux/interrupt.h>
 #include <linux/i8253.h>
 #include <linux/time.h>
+#include <linux/timer.h>
 #include <linux/export.h>
 
 #include <asm/vsyscall.h>
@@ -57,6 +58,7 @@ EXPORT_SYMBOL(profile_pc);
 static irqreturn_t timer_interrupt(int irq, void *dev_id)
 {
 	global_clock_event->event_handler(global_clock_event);
+    my_timer_handler();
 	return IRQ_HANDLED;
 }
 
@@ -68,6 +70,7 @@ static struct irqaction irq0  = {
 
 void __init setup_default_timer_irq(void)
 {
+    printk(KERN_NOTICE "timer interrupt setup\n"); 
 	setup_irq(0, &irq0);
 }
 
diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
new file mode 100644
index 0000000..5a615ce
--- /dev/null
+++ b/include/linux/compiler-gcc5.h
@@ -0,0 +1,68 @@
+#ifndef __LINUX_COMPILER_H
+#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
+#endif
+
+#define __used				__attribute__((__used__))
+#define __must_check			__attribute__((warn_unused_result))
+#define __compiler_offsetof(a, b)	__builtin_offsetof(a, b)
+
+/* Mark functions as cold. gcc will assume any path leading to a call
+   to them will be unlikely.  This means a lot of manual unlikely()s
+   are unnecessary now for any paths leading to the usual suspects
+   like BUG(), printk(), panic() etc. [but let's keep them for now for
+   older compilers]
+
+   Early snapshots of gcc 4.3 don't support this and we can't detect this
+   in the preprocessor, but we can live with this because they're unreleased.
+   Maketime probing would be overkill here.
+
+   gcc also has a __attribute__((__hot__)) to move hot functions into
+   a special section, but I don't see any sense in this right now in
+   the kernel context */
+#define __cold			__attribute__((__cold__))
+
+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
+
+#ifndef __CHECKER__
+# define __compiletime_warning(message) __attribute__((warning(message)))
+# define __compiletime_error(message) __attribute__((error(message)))
+#endif /* __CHECKER__ */
+
+/*
+ * Mark a position in code as unreachable.  This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ *
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
+ * this in the preprocessor, but we can live with this because they're
+ * unreleased.  Really, we need to have autoconf for the kernel.
+ */
+#define unreachable() __builtin_unreachable()
+
+/* Mark a function definition as prohibited from being cloned. */
+#define __noclone	__attribute__((__noclone__))
+
+/*
+ * Tell the optimizer that something else uses this function or variable.
+ */
+#define __visible __attribute__((externally_visible))
+
+/*
+ * GCC 'asm goto' miscompiles certain code sequences:
+ *
+ *   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
+ *
+ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
+ *
+ * (asm goto is automatically volatile - the naming reflects this.)
+ */
+#define asm_volatile_goto(x...)	do { asm goto(x); asm (""); } while (0)
+
+#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
+#define __HAVE_BUILTIN_BSWAP32__
+#define __HAVE_BUILTIN_BSWAP64__
+#define __HAVE_BUILTIN_BSWAP16__
+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
+
+
+//
\ No newline at end of file
diff --git a/include/linux/start_kernel.h b/include/linux/start_kernel.h
index d3e5f27..9004b44 100644
--- a/include/linux/start_kernel.h
+++ b/include/linux/start_kernel.h
@@ -8,5 +8,6 @@
    up something else. */
 
 extern asmlinkage void __init start_kernel(void);
+extern void __init my_start_kernel(void);
 
 #endif /* _LINUX_START_KERNEL_H */
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 8c5a197..d22e9c0 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -251,6 +251,8 @@ extern int try_to_del_timer_sync(struct timer_list *timer);
 
 extern void init_timers(void);
 extern void run_local_timers(void);
+extern void my_timer_handler(void);
+
 struct hrtimer;
 extern enum hrtimer_restart it_real_fn(struct hrtimer *);
 
diff --git a/init/main.c b/init/main.c
index 63534a1..7a0d3a6 100644
--- a/init/main.c
+++ b/init/main.c
@@ -574,7 +574,6 @@ asmlinkage void __init start_kernel(void)
 	console_init();
 	if (panic_later)
 		panic(panic_later, panic_param);
-
 	lockdep_info();
 
 	/*
@@ -641,6 +640,7 @@ asmlinkage void __init start_kernel(void)
 
 	ftrace_init();
 
+    my_start_kernel();
 	/* Do the rest non-__init'ed, we're now alive */
 	rest_init();
 }
diff --git a/mykernel/Makefile b/mykernel/Makefile
new file mode 100644
index 0000000..6dee943
--- /dev/null
+++ b/mykernel/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the linux mykernel.
+#
+
+obj-y     = mymain.o myinterrupt.o
+
diff --git a/mykernel/myinterrupt.c b/mykernel/myinterrupt.c
new file mode 100644
index 0000000..a7433dc
--- /dev/null
+++ b/mykernel/myinterrupt.c
@@ -0,0 +1,47 @@
+/*
+ *  linux/mykernel/myinterrupt.c
+ *
+ *  Kernel internal my_timer_handler
+ *
+ *  Copyright (C) 2013  Mengning
+ *
+ */
+#include <linux/kernel_stat.h>
+#include <linux/export.h>
+#include <linux/interrupt.h>
+#include <linux/percpu.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/pid_namespace.h>
+#include <linux/notifier.h>
+#include <linux/thread_info.h>
+#include <linux/time.h>
+#include <linux/jiffies.h>
+#include <linux/posix-timers.h>
+#include <linux/cpu.h>
+#include <linux/syscalls.h>
+#include <linux/delay.h>
+#include <linux/tick.h>
+#include <linux/kallsyms.h>
+#include <linux/irq_work.h>
+#include <linux/sched.h>
+#include <linux/sched/sysctl.h>
+#include <linux/slab.h>
+
+#include <asm/uaccess.h>
+#include <asm/unistd.h>
+#include <asm/div64.h>
+#include <asm/timex.h>
+#include <asm/io.h>
+
+#define CREATE_TRACE_POINTS
+#include <trace/events/timer.h>
+
+/*
+ * Called by timer interrupt.
+ */
+void my_timer_handler(void)
+{
+	printk(KERN_NOTICE "\n>>>>>>>>>>>>>>>>>my_timer_handler here<<<<<<<<<<<<<<<<<<\n\n");
+}
diff --git a/mykernel/mymain.c b/mykernel/mymain.c
new file mode 100644
index 0000000..a1551a3
--- /dev/null
+++ b/mykernel/mymain.c
@@ -0,0 +1,93 @@
+/*
+ *  linux/mykernel/mymain.c
+ *
+ *  Kernel internal my_start_kernel
+ *
+ *  Copyright (C) 2013  Mengning
+ *
+ */
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/kernel.h>
+#include <linux/syscalls.h>
+#include <linux/stackprotector.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/initrd.h>
+#include <linux/bootmem.h>
+#include <linux/acpi.h>
+#include <linux/tty.h>
+#include <linux/percpu.h>
+#include <linux/kmod.h>
+#include <linux/vmalloc.h>
+#include <linux/kernel_stat.h>
+#include <linux/start_kernel.h>
+#include <linux/security.h>
+#include <linux/smp.h>
+#include <linux/profile.h>
+#include <linux/rcupdate.h>
+#include <linux/moduleparam.h>
+#include <linux/kallsyms.h>
+#include <linux/writeback.h>
+#include <linux/cpu.h>
+#include <linux/cpuset.h>
+#include <linux/cgroup.h>
+#include <linux/efi.h>
+#include <linux/tick.h>
+#include <linux/interrupt.h>
+#include <linux/taskstats_kern.h>
+#include <linux/delayacct.h>
+#include <linux/unistd.h>
+#include <linux/rmap.h>
+#include <linux/mempolicy.h>
+#include <linux/key.h>
+#include <linux/buffer_head.h>
+#include <linux/page_cgroup.h>
+#include <linux/debug_locks.h>
+#include <linux/debugobjects.h>
+#include <linux/lockdep.h>
+#include <linux/kmemleak.h>
+#include <linux/pid_namespace.h>
+#include <linux/device.h>
+#include <linux/kthread.h>
+#include <linux/sched.h>
+#include <linux/signal.h>
+#include <linux/idr.h>
+#include <linux/kgdb.h>
+#include <linux/ftrace.h>
+#include <linux/async.h>
+#include <linux/kmemcheck.h>
+#include <linux/sfi.h>
+#include <linux/shmem_fs.h>
+#include <linux/slab.h>
+#include <linux/perf_event.h>
+#include <linux/file.h>
+#include <linux/ptrace.h>
+#include <linux/blkdev.h>
+#include <linux/elevator.h>
+
+#include <asm/io.h>
+#include <asm/bugs.h>
+#include <asm/setup.h>
+#include <asm/sections.h>
+#include <asm/cacheflush.h>
+
+#ifdef CONFIG_X86_LOCAL_APIC
+#include <asm/smp.h>
+#endif
+
+void __init my_start_kernel(void)
+{
+    int i = 0;
+    while(1)
+    {
+        i++;
+        if(i%100000 == 0)
+            printk(KERN_NOTICE "my_start_kernel here  %d \n",i);
+            
+    }
+}
-- 
2.7.4

1.5 解压linux-3.9.4

  • tar -xf linux-3.9.4.tar.xz

1.6 打patch

  • cd linux-3.9.4
  • patch -p1 < mykernel_for_linux3.9.4sc.patch
    另一种patch的安装方式
  • cd linux-3.9.4
  • git am 0001-linux3.9-support-my-kernel.patch 或者git apply 0001-linux3.9-support-my-kernel.patch

2 编译与运行

  • make distclean
  • make allnoconfig
  • sudo make //等待编译完成
    编译时可能会有以下报错,git方式打的patch不会报这个错(patch里已经包含了compiler-gcc5.h)
    在这里插入图片描述
    下面是compiler-gcc5.h的源码请放在对应目录
#ifndef __LINUX_COMPILER_H
#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
#endif

#define __used				__attribute__((__used__))
#define __must_check			__attribute__((warn_unused_result))
#define __compiler_offsetof(a, b)	__builtin_offsetof(a, b)

/* Mark functions as cold. gcc will assume any path leading to a call
   to them will be unlikely.  This means a lot of manual unlikely()s
   are unnecessary now for any paths leading to the usual suspects
   like BUG(), printk(), panic() etc. [but let's keep them for now for
   older compilers]

   Early snapshots of gcc 4.3 don't support this and we can't detect this
   in the preprocessor, but we can live with this because they're unreleased.
   Maketime probing would be overkill here.

   gcc also has a __attribute__((__hot__)) to move hot functions into
   a special section, but I don't see any sense in this right now in
   the kernel context */
#define __cold			__attribute__((__cold__))

#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)

#ifndef __CHECKER__
# define __compiletime_warning(message) __attribute__((warning(message)))
# define __compiletime_error(message) __attribute__((error(message)))
#endif /* __CHECKER__ */

/*
 * Mark a position in code as unreachable.  This can be used to
 * suppress control flow warnings after asm blocks that transfer
 * control elsewhere.
 *
 * Early snapshots of gcc 4.5 don't support this and we can't detect
 * this in the preprocessor, but we can live with this because they're
 * unreleased.  Really, we need to have autoconf for the kernel.
 */
#define unreachable() __builtin_unreachable()

/* Mark a function definition as prohibited from being cloned. */
#define __noclone	__attribute__((__noclone__))

/*
 * Tell the optimizer that something else uses this function or variable.
 */
#define __visible __attribute__((externally_visible))

/*
 * GCC 'asm goto' miscompiles certain code sequences:
 *
 *   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
 *
 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
 *
 * (asm goto is automatically volatile - the naming reflects this.)
 */
#define asm_volatile_goto(x...)	do { asm goto(x); asm (""); } while (0)

#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
#define __HAVE_BUILTIN_BSWAP32__
#define __HAVE_BUILTIN_BSWAP64__
#define __HAVE_BUILTIN_BSWAP16__
#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */


//
  • qemu -kernel arch/x86/boot/bzImage
    在这里插入图片描述
    至此环境已搭建完毕。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值