s3c2410平台下linux四键按键驱动程序
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include<linux/config.h>
#include<linux/module.h>
#include<linux/version.h>
#include<linux/init.h>
#include<linux/kernel.h>
#include<linux/errno.h>
#include<linux/sched.h>//声明中断
#include<linux/fs.h>//声明file文件
#include<asm/system.h>/*cli(),*_flages*/
#include<linux/poll.h>
#include<linux/types.h>
#include<linux/slab.h>
#include <asm/arch/S3C2410.h>
#include <asm/hardware.h>//devf
//-------------------------------
#include <asm/io.h>/* ioremap */
#include <linux/delay.h>
#include <asm/delay.h>
//--------------------------------
#include <asm-arm/arch-s3c2410/smdk.h>
#include <linux/ioport.h>
#include <asm/irq.h>
#include <asm/mach/irq.h>
//define the interrupt No.
#define interrupt_k4 IRQ_EINT0
#define interrupt_k3 IRQ_EINT2
#define interrupt_k2 IRQ_EINT11
#define interrupt_k1 IRQ_EINT19
/*
struct IRQ_STRUCT
{
unsigned int irq_no;
void (*irq_fun)();
};
static IRQ_STRUCT irq_struct[4];
*/
//定义键盘的主设备号define the major of keypad
#define KEYPAD_MAJOR 59
#ifndef MOD_INC_USE_COUNT
#define MOD_INC_USE_COUNT
#endif
#ifndef MOD_DEC_USE_COUNT
#define MOD_DEC_USE_COUNT
#endif
#define COMMAND1 1
#define KBD_GETKEY 1
static int keyvalue;
#define DEVICE_NAME "keypad"
//setup the GPIO F ports register
#define key_rGPFCON (*(volatile unsigned long *) key_r_GPFCON)
#define key_rGPFUP (*(volatile unsigned long *) key_r_GPFUP)
#define key_rGPFDAT (*(volatile unsigned long *) key_r_GPFDAT)
//setup the GPIO G ports register
#define key_rGPGCON (*(volatile unsigned long *) key_r_GPGCON)
#define key_rGPGUP (*(volatile unsigned long *) key_r_GPGUP)
#define key_rGPGDAT (*(volatile unsigned long *) key_r_GPGDAT)
unsigned long *key_r_GPFCON, *key_r_GPFDAT,
相关文档:
第一步:在VMWARE中,运行启动LINUX后。点击VM->INSTALL VMWare TOOLS,点击OK。(补充:退出VMWARE回到XP用CTRL+ALT)
第二步:进入LINUX后,运行终端。执行mount /dev/cdrom以文件方式挂载光驱(如果没有第一步,就没有这一步,因为需要的TOOLS是以光驱文件形式存放) ......
以下在centos5.3上实验。在linux中signal函数是通过调用sigaction来实现的,由此它不存在信号丢失以及每次信号处理后会把信号处理改成默认处理方式。但对于系统调用函数被信号打断时,系统调用是否会自动启动好像没怎么说明。不过可以自己动手看一下:
signal(SIGTERM, term_handle ......
转自:
http://www.ibm.com/developerworks/cn/linux/kernel/syscall/part1/appendix.html
本文列出了大部分常见的Linux系统调用,并附有简要中文说明。
以下是Linux系统调用的一个列表,包含了大部分常用系统调用和由系统调用派生出的的函数。这可能是你在互联网上所能看到的唯一一篇中文注释的Linux系统调用列表,即使 ......
在linux内核中用于申请中断的函数是request_irq(),函数原型在Kernel/irq/manage.c中定义:
int request_irq(unsigned int irq, irq_handler_t handler,
unsigned ......
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstring>
using namespace std;
void peek_interfaces(int ......