mirror of
https://github.com/gatieme/LDD-LinuxDeviceDrivers.git
synced 2026-08-19 01:22:36 +08:00
获取gdt...
This commit is contained in:
@@ -0,0 +1 @@
|
||||
cmd_/home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/03-vmarea/00-code/02-gdt_table/get_gdt_table.ko := ld -r -m elf_x86_64 -T ./scripts/module-common.lds --build-id -o /home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/03-vmarea/00-code/02-gdt_table/get_gdt_table.ko /home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/03-vmarea/00-code/02-gdt_table/get_gdt_table.o /home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/03-vmarea/00-code/02-gdt_table/get_gdt_table.mod.o
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
||||
/home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/03-vmarea/00-code/02-gdt_table/get_gdt_table.ko
|
||||
/home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/03-vmarea/00-code/02-gdt_table/get_gdt_table.o
|
||||
@@ -16,6 +16,54 @@
|
||||
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
|
||||
|
||||
#define BitGet(number, pos) ((number) >> (pos) & 1) /// 用宏得到某数的某位
|
||||
#define BitSet(number, pos) ((number) |= 1 << (pos)) /// 把某位置1
|
||||
#define BitClr(number, pos) ((number) &= ~(1 << (pos))) /// 把某位清0
|
||||
#define BitCpl(number, pos) ((number) ^= 1 << (pos)) /// 把number的POS位取反
|
||||
|
||||
|
||||
// http://lxr.free-electrons.com/source/arch/x86/include/asm/segment.h#L123
|
||||
static void print_segment(void)
|
||||
{
|
||||
long data = 0;
|
||||
|
||||
/*
|
||||
|
||||
---------------------------------------------------------------------------------------------
|
||||
| | INDEX | TI| RPL |
|
||||
---------------------------------------------------------------------------------------------
|
||||
__KERNEL_CS = 0x0010 = B 0 0 0 0 0 0 0 0 0 0 0 1 0 | 0 | 0 0 | index = 2, TI = 0, RPL = 0
|
||||
---------------------------------------------------------------------------------------------
|
||||
__KERNEL_DS = 0x0018 = B 0 0 0 0 0 0 0 0 0 0 0 1 1 | 0 | 0 0 | index = 3, TI = 0, RPL = 0
|
||||
---------------------------------------------------------------------------------------------
|
||||
__USER_DS = 0x0033 = B 0 0 0 0 0 0 0 0 0 0 1 1 0 | 0 | 1 1 | index = 6, TI = 0, RPL = 3
|
||||
---------------------------------------------------------------------------------------------
|
||||
__USER_DS = 0x002B = B 0 0 0 0 0 0 0 0 0 0 1 0 1 | 0 | 1 1 | index = 5, TI = 0, RPL = 3
|
||||
---------------------------------------------------------------------------------------------
|
||||
|
||||
| LE little-endian | 低字节 -=> 高字节 |
|
||||
---------------------------------------------------------------------------------------------
|
||||
__KERNEL_CS = 0x0010 = | 00010000 00000000 |
|
||||
__KERNEL_DS = 0x0018 = | 00011000 00000000 |
|
||||
__USER_DS = 0x0033 = | 00110011 00000000 |
|
||||
__USER_DS = 0x002B = | 00101011 00000000 |
|
||||
*/
|
||||
data = __KERNEL_CS;
|
||||
printk("__KERNEL_CS = %0x\n", data);
|
||||
|
||||
data = __KERNEL_DS;
|
||||
printk("__KERNEL_DS = %0x\n", data);
|
||||
|
||||
data = __USER_CS;
|
||||
printk("__USER_CS = %0x\n", data);
|
||||
|
||||
data = __USER_DS;
|
||||
printk("__USER_DS = %0x\n", data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void print_desc_struct(struct desc_struct *desc)
|
||||
{
|
||||
#if 0
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/vermagic.h>
|
||||
#include <linux/compiler.h>
|
||||
|
||||
MODULE_INFO(vermagic, VERMAGIC_STRING);
|
||||
|
||||
__visible struct module __this_module
|
||||
__attribute__((section(".gnu.linkonce.this_module"))) = {
|
||||
.name = KBUILD_MODNAME,
|
||||
.init = init_module,
|
||||
#ifdef CONFIG_MODULE_UNLOAD
|
||||
.exit = cleanup_module,
|
||||
#endif
|
||||
.arch = MODULE_ARCH_INIT,
|
||||
};
|
||||
|
||||
static const struct modversion_info ____versions[]
|
||||
__used
|
||||
__attribute__((section("__versions"))) = {
|
||||
{ 0x9d35aeec, __VMLINUX_SYMBOL_STR(module_layout) },
|
||||
{ 0x5ecfeec6, __VMLINUX_SYMBOL_STR(__per_cpu_offset) },
|
||||
{ 0x37f1ffbf, __VMLINUX_SYMBOL_STR(gdt_page) },
|
||||
{ 0x27e1a049, __VMLINUX_SYMBOL_STR(printk) },
|
||||
{ 0xbdfb6dbb, __VMLINUX_SYMBOL_STR(__fentry__) },
|
||||
};
|
||||
|
||||
static const char __module_depends[]
|
||||
__used
|
||||
__attribute__((section(".modinfo"))) =
|
||||
"depends=";
|
||||
|
||||
|
||||
MODULE_INFO(srcversion, "453437B362D9501283E72EE");
|
||||
@@ -0,0 +1 @@
|
||||
kernel//home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/03-vmarea/00-code/02-gdt_table/get_gdt_table.ko
|
||||
Reference in New Issue
Block a user