搜索
 共有 5 条信息    默认    按推荐    按免费    按付费   按浏览量    按下载量    专题列表
推荐下载
最新专题
      暂无相关信息
0 次点评
界面 NAN
功能 NAN

Writing an ACPI driver Using Gpio as SCI to Nofity Application under Linux

分类:Linux驱动    下载:0    浏览:153    时间:2018-09-07
Writing an ACPI driver Using Gpio as SCI to Nofity Application under LinuxSeptember 6, 2018This article was contributed by jason_tThe Advanced Configuration and Power Interface specification (ACPI) was introduced to replace the myriad of differing protocols for providing configuration data to the operating system. It additionally provided a new power control specification to replace APM, moving policy decisions out of the hard-coded BIOS and into the operating system. Since then it's had a number of extensions implementing all kinds of functionality, variously specified and unspecified. Hardware vendors have seized upon this to implement their own custom "value add" interfaces, taking advantage of the existing specified functionality while adding their own non-standard extensions.In this article we'll be looking at writing a driver to manage a user defined virtual asl device on x86 pc. According to the ACPI specification, the user defined virtual devices can be 7 characters like NSC1100, SMCF030, In this example we use TTS7205 as example:Scope(\_SB.PCI0.LPCB){ Device(TTST) { Name(_HID, EISAID("TTS7205")) Name(_UID, 0x00) Name(_STA, 0x0F) Method(FSTR, 0, Notserialized) { P8XH(0,0x77) Store(2, \_SB.PCI0.LPCB.G0RU) //route GPI0 to SCI Store(1, GPE0) //enable GPE0 } }}在ASL中将GPIO0的SCI handler中想驱动发送NofityScope(\_GPE){ Method(_L10) { //Store(0x10,P80D) //P8XH(0,0x10) Notify(\_SB.PCI0.LPCB.TTST, 0x80) }}At this point we can write a basic driver that does nothing other than bind to this ACPI device. It's only a few lines of code to do that, and it's consistent between all ACPI drivers. All we need to do is register an ACPI driver structure with add and remove functions. These will be called whenever the kernel finds an ACPI device with the TTS7205 ID, and we can do further setup there.#include #include #include #include #include #include #include #include #include #include #define MODULE_NAME "drvAcpi" /* module name */#define DEVICE_NAME "acpisci" /* device name */static const struct acpi_device_id bt_device_ids[] ={ { "TTS7205", 0}, { "", 0},};MODULE_DEVICE_TABLE(acpi, bt_device_ids);static struct acpi_driver acpi_sci_driver ={ .name = "DrvAcpi", .ids = bt_device_ids, .ops = { .add = acpi_sci_add, .remove = acpi_sci_remove, .notify = acpi_sci_notify, }, .owner = THIS_MODULE,};static int acpi_sci_add(struct acpi_device *device){ printk(KERN_DEBUG "%s: %s(): acpi_sci_add\n", MODULE_NAME, __func__); return toshiba_bluetooth_enable(device->handle);}#if 0 /* for support kernel 4.4.0-31 */static int acpi_sci_remove(struct acpi_device *device, int type)#elsestatic int acpi_sci_remove(struct acpi_device *device)#endif{ acpi_status result; acpi_integer status; printk(KERN_DEBUG "%s: %s(): acpi_sci_remove\n\r", MODULE_NAME, __func__); printk(KERN_DEBUG "%s: %s(): evaluate FSTP() acpi method.\n", MODULE_NAME, __func__); result = acpi_evaluate_integer(device->handle, "FSTP", NULL, &status); if (ACPI_FAILURE(result)) { printk(KERN_DEBUG "%s: %s(): error - FSTP() acpi method not found.\n", MODULE_NAME, __func__); return -EINVAL; } return 0;}static void acpi_sci_notify(struct acpi_device *device, u32 event){ DPRINTK(KERN_DEBUG "%s: %s(): received a notify. value = 0x%02X. count = %lld.\n", MODULE_NAME, __func__, event, ++count); ......}static struct file_operations acpi_drv_fops ={ .owner = THIS_MODULE, /* MACRO, point to __this_module Variable */ .open = acpi_drv_open, .read = acpi_drv_read, .release = acpi_drv_close, .poll = acpi_drv_poll, .fasync = acpi_drv_fasync,};On the other side, when we complete compiling acpi asl driver ko kernel module, we can operate this user device under linux os.#include #include #include #include #include #include #include #include #include /* fifthdrvtest */int fd;long long count = 0;//信号处理函数void my_signal_fun(int signum){ //unsigned char key_val; //read(fd, &key_val, 1); printf("key_val: hello - count = %lld.\n", ++count);}int main(int argc, char **argv){ unsigned char key_val; int ret; int Oflags; //在应用程序中捕捉SIGIO信号(由驱动程序发送) signal(SIGIO, my_signal_fun); fd = open("/dev/acpisci", O_RDWR); if (fd < 0) { printf("can't open!\n"); } //将当前进程PID设置为fd文件所对应驱动程序将要发送SIGIO,SIGUSR信号进程PID fcntl(fd, F_SETOWN, getpid()); //获取fd的打开方式 Oflags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, Oflags | FASYNC); while (1) { sleep(1000); } return 0;}oops! complete!
1 次点评
界面 5
功能 5

Windows下自定义ACPI虚拟设备Driver及示例APP源码

分类:Windows驱动    下载:2    浏览:263    时间:2018-09-07
目录结构:AcpiDriverProj_v1.2 \app \asl \inf \sys该示例程序再LPC设备下虚拟一个TEST的自定义设备,在Windows系统下将driver安装在该自定义设备上;- 可通过Windows系统下的APP透过driver来执行BIOS中指定的ASL code fucniton,- 可通过Asl code中的Notify function来通知driver,并将event最终反馈给App。可配合硬件GPIO和SCI中间达到通过应用程序的目的。driver中的Nofity HandlerVOIDAbcdDeviceNotifyHandler ( IN PVOID Context, IN ULONG NotifyValue )/*Routine Description: This routine fields my device notifications from the ACPI driver.Arguments: Context - For the device. NotifyValue - Input argument.Return Value: None*/{ KdPrint(("dklsafjldksjflkasdjflkasdjfk\n")); switch (NotifyValue) { case ABCD_DEVICE_INFO_CHANGE: // Notify value is 0x80 { //AbcdDev->IsInfoChanged = TRUE; KdPrint(("111111111111111111111111111\n")); KeSetEvent(event, 0, FALSE); KdPrint(("KeSetEvent sussfully!\n")); break; } default: break; }}BIOS中的ASL Code,或这用Acpi tool手动导入自定义DSDT AML文件也可以//***********************************************************************//Title: TEST.asl//Version:0.01//***********************************************************************Scope(\_SB){ Device(TEST) { Name(_HID,"TEST0001") Name(_UID,0) Name(VALU,0) // Methods and other definition which will described in next section Method(GIDV,1,NOTSerialized) //Get TEST Device Version { Notify(\_SB.TEST,0x80) And(Arg0, 0xff, Local0) Add(Local0, 5, Local0) Return(Local0) } Method(_STA,0,NOTSerialized) { Return(0x0F) } }}
0 次点评
界面 NAN
功能 NAN

PCI.Express.Base.Specification.v2.0

分类:Specification    下载:3    浏览:172    时间:2018-09-07
0 次点评
界面 NAN
功能 NAN

RW-Everything

分类:Tools    下载:36    浏览:235    时间:2018-09-07
This utility access almost all the computer hardware, including PCI (PCI Express), PCI Index/Data, Memory, Memory Index/Data, I/O Space, I/O Index/Data, Super I/O, Clock Generator, DIMM SPD, SMBus Device, CPU MSR Registers, ATA/ATAPI Identify Data, Disk Read Write, ACPI Tables Dump (include AML decode), Embedded Controller, USB Information, SMBIOS Structures, PCI Option ROMs, MP Configuration Table, E820, EDID and Remote Access. And also a Command Window is provided to access hardware manually.Powerful utility for hardware engineers, firmware (BIOS) engineers, driver developers, QA engineers, performance test engineers, diagnostic engineers, etc.This utility comes with ABSOLUTELY NO WARRANTY, it allows you to modify hardware settings, this may damage your system if something goes wrong. Author will not take any responsibility about that, you are on your own risk.This utility should not be used in commercial or consumer products.v1.7 8/19/2017Support ACPI 6.1.Support Intel Apollo Lake smbus.v1.6.9 7/2/2016Support ASL external 0x15 opcode (ACPI 6.0).New command line parameter: LogAppend, LogDate and LogTime.New MMIO function.v1.6.8.4 3/15/2016Fix MSR bit edit function.Fix command line console redirection.v1.6.8.3 3/6/2016Fix ACPI ASF table decode issue.Improve MSR function: separate MTRR and user define registers.Support skylake DDR4 SPD.v1.6.8.1 8/21/2015Fix XP API entry not found issue.Fix SMBIOS version control issue.Minor bug fixed.v1.6.8 8/6/2015Modify MSR function to support more than 64 processors (processor group).Add apply to all CPUs option in MSR edit function.v1.6.7 12/19/2014Fixed ACPI FDPT decode issue.Support Win PE environment.Support SPD write function.v1.6.6.1 9/30/2014Improve ACPI decode function.Add /NoLogo parameter.Support X99 chipset DDR4 SPD.Fix CPU MSR write function.Minor bug fixed.v1.6.5.9 1/6/2014Improve ACPI decode function.Fix XP 32bit missing API error.v1.6.5 10/25/2013Improve ACPI table searching method.Change IO space access length according to the display width (byte/word/dword).Support BayTrail smbus controller.Support unpartitioned disk read/write.Improve start up speed.v1.6.4 05/29/2013Monitor USB device change event to update USB info.Add SMBIOS command script.Fix help file cannot be opened issue.Fix native 64bit exception issue.Fix command line script issue.Fix CPUID command.Change CPU speed to bus speed.Add PCIE base detect option.v1.6 05/07/2013Support native 64bit.Add USB 3.0 speed (super speed) info.Fix SPD DIMM menu shift issue.Give warning if trying to over write saved file.Minor improvement and bug fix.v1.5.3.7 11/01/2012Fix ACPI function short-cut key issue.Fix SMBios structure type 14.Fix USB info device description.Re-support E820, PCITree, PCIRes command.v1.5.3.1 09/10/2012Fix WRMSR command error.v1.5.3 06/09/2012Fix ACPI DMAR table.Fix option rom save to file function.Save all last open windows for auto start on next launch.Add ACPI FPDT table support.Improve cout and setenv command.
0 次点评
界面 NAN
功能 NAN

test

分类:DOS工具    下载:1    浏览:114    时间:2018-09-02
aadsfasdfadsfadsfadsfadsfdaf123

QQ|Archiver|手机版|小黑屋|RD之家 - 研发工程师的伊甸园 ( 京ICP备18037383号 )
360导航 360安全浏览器 蚂蚁搜索 速搜全球 酷帝网站目录 搜狗导航 114啦网址导航

GMT+8, 2018-11-14 08:48

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部