One: Ioremap
In the kernel, the mapping to the physical address to the virtual address is all there is the MMU, unified open, and the physical address to the virtual address of the mapping relationship all there is a corresponding table inside, this table, in the opening of the MMU together, the building, For example, when building a table is to map the physical address 0x11111111 to 44444444, then the problem is: for example, if we want to map 0x11111111 address to 66666666 address? In the kernel, a specific physical address to the virtual address of the automatic mapping through the Ioremap () function to achieve
1#include <linux/init.h>2#include <linux/thread_info.h>3#include <linux/module.h>4#include <linux/sched.h>5#include <linux/errno.h>6#include <linux/kernel.h>7#include <linux/module.h>8#include <linux/slab.h>9#include <linux/input.h>Ten#include <linux/init.h> One#include <linux/serio.h> A#include <linux/delay.h> -#include <linux/clk.h> -#include <linux/miscdevice.h> the#include <linux/io.h> -#include <linux/ioport.h> -#include <asm/uaccess.h> - +#include <linux/gpio.h> -#include <mach/gpio.h> +#include <plat/gpio-cfg.h> A at -Module_license ("GPL"); -Module_author ("Bunfly"); - -UnsignedLongGpio_virt =0; - in intTest_init () - { to void__iomem *p; + -p = request_mem_region (0x11000000, sz_4k,"Gpio");//Register Memory mapping information the if(p==NULL) * { $Printk"Request error!\n"); Panax Notoginseng return 1; - } the +Gpio_virt = Ioremap (0x11000000, sz_4k); A //Ioremap physical memory to virtual memory mapping the* (unsignedLong*) (Gpio_virt +0x2e0) =1; +* (unsignedLong*) (Gpio_virt +0x2e4) =0; -Printk"Hello led!\n"); $ $Printk"Phys:%p\n", Virt_to_phys (Gpio_virt)); - - return 0; the } - Wuyi voidtest_exit () the { -Printk"Bye bye!\n"); WuIounmap (gpio_virt); -Release_mem_region (0x11000000, sz_4k); About //Cancel the mapped virtual memory when exiting $ } - -Module_init (test_init); -Module_exit (test_exit); A + the -
This is done by mapping the physical memory to virtual memory, and then by manipulating the virtual memory to light the
When the kernel is assigned, it registers the assigned name, and the registration information can be viewed under the board's directory:
Cat/proc/iomem
Attention:
In order to eliminate the effects of the LED modules that are in the kernel, the LED modules that are brought into the module are required before the modules are run:
Make Menuconfig under the Linux_3
After saving the exit, re-make the zimage file, download to the board, run.
II: Internal watch watchdog interrupt
Linux kernel interrupt (IOREMAP, internal watchdog interrupt, external interrupt)