kernel

how does the OS know the real size of the physical memory?

佐手、 提交于 2020-01-02 04:25:15
问题 When the OS is loaded at the moment the computer is started, how does the OS know the hardware information, is there some io instruction or the booter program get information from the bios.?? 回答1: The motherboard firmware (also called BIOS, ACPI interface or EFI) allows the OS to find out the physical mapping of RAM and ROM in the system. For example, this is the output of a booting Linux: [ 0.000000] BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: 0000000000000000 - 0000000000098c00

How to arrange a Makefile to compile a kernel module with multiple .c files?

北战南征 提交于 2020-01-02 02:56:15
问题 How to arrange a Makefile to compile a kernel module with multiple .c files? Here is my current Makefile. It was auto generated by KDevelop TARGET = nlb-driver OBJS = nlb-driver.o MDIR = drivers/misc EXTRA_CFLAGS = -DEXPORT_SYMTAB CURRENT = $(shell uname -r) KDIR = /lib/modules/$(CURRENT)/build PWD = $(shell pwd) DEST = /lib/modules/$(CURRENT)/kernel/$(MDIR) obj-m += $(TARGET).o default: make -C $(KDIR) M=$(PWD) modules $(TARGET).o: $(OBJS) $(LD) $(LD_RFLAG) -r -o $@ $(OBJS) ifneq (,$

How do I trace a system call in Linux?

馋奶兔 提交于 2020-01-02 02:40:20
问题 How would I follow a system call from a trap to the kernel, to how arguments are passed, to how the system call in located in the kernel, to the actual processing of the system call in the kernel, to the return back to the user and how state is restored? 回答1: SystemTap This is the most powerful method I've found so far. It can even show the call arguments: Does ftrace allow capture of system call arguments to the Linux kernel, or only function names? Usage: sudo apt-get install systemtap sudo

error compiling: linux/module.h: No such file or directory

泪湿孤枕 提交于 2020-01-02 00:56:10
问题 I've written a simple module: #define __KERNEL__ #define MODULE #include <linux/kernel.h> #include <linux/module.h> int init_module(void) { printk("Hello, world\n"); return 0; } void cleanup_module(void) { printk("Goodbye\n"); } and compiling it with this command: cc -c hello.c but I'm getting this error: linux/module.h: No such file or directory any suggestions? EDIT: I used this commad: cc -I/usr/src/linux-headers-3.0.0-17-generic/include -c hello.c and it goes one step ahead, now I get

why is u8 u16 u32 u64 used instead of unsigned int in kernel programming

霸气de小男生 提交于 2020-01-02 00:27:05
问题 I see u8 u16 u32 u64 data types being used in kernel code. And I am wondering why is there need to use u8 or u16 or u32 or u64 and not unsigned int ? 回答1: Often when working close to the hardware or when trying to control the size/format of a data structure you need to have precise control of the size of your integers. As for u8 vs uint8_t , this is simply because Linux predated <stdint.h> being available in C, which is technically a C99-ism, but in my experience is available on most modern

Linux kernel hardware break points

跟風遠走 提交于 2020-01-01 17:12:32
问题 I want to build a simple linux kernel debugger for the x86 architecture. I first want it to set break points. I was wondering if there is a kernel api for configuring the debugger registers and if so any good documentation? If there is no kernel api for debugger registers is there any documentation on how to properly configure the registers manually(using the assembly "MOV" instruction)? 回答1: It depends on which kernel versions you would like to handle. There is an API for setting hardware

How can I work out what events are being waited for with WinDBG in a kernel debug session

坚强是说给别人听的谎言 提交于 2020-01-01 16:51:47
问题 I'm a complete WinDbg newbie and I've been trying to debug a WindowsXP problem that a customer has sent me where our software and some third party software prevent windows from logging off. I've reproduced the problem and have verified that only when our software and the customers software are both installed (although not necessarily running at logoff) does the log off problem occur. I've observed that WM_ENDSESSION messages are not reaching the running windows when the user tries to log off

Toy OS Filesystem [closed]

故事扮演 提交于 2020-01-01 16:25:18
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I have developed a basic kernel in assembly/c that runs a basic terminal. I have set it up to run off of an iso with grub. I would like to continue this OS, but without a file system, I feel as if there's really nothing else I could do. After much time on the internet, I have come

Keyboard interrupt handler for own kernel (C)

流过昼夜 提交于 2020-01-01 16:07:30
问题 I am writing a tiny OS as part of an assigment for school,but I got stuck when it comes to get keyboard input (press a key -> display it on screen). I am using the Bare Bones tutorial from osdev.org (gcc cross-compiler, GRUB bootloader, ld linker) and since I am in protected mode I can not use BIOS interrupts for input, that's why I have to write my own interrupt handler (?) but I'm not sure how to do that even after I read some osdev articles and forum discussions. Very similar problem (http

Keyboard interrupt handler for own kernel (C)

泪湿孤枕 提交于 2020-01-01 16:06:55
问题 I am writing a tiny OS as part of an assigment for school,but I got stuck when it comes to get keyboard input (press a key -> display it on screen). I am using the Bare Bones tutorial from osdev.org (gcc cross-compiler, GRUB bootloader, ld linker) and since I am in protected mode I can not use BIOS interrupts for input, that's why I have to write my own interrupt handler (?) but I'm not sure how to do that even after I read some osdev articles and forum discussions. Very similar problem (http