device-driver

Get Rotation Speed of Disk Sample Code

試著忘記壹切 提交于 2019-12-05 09:07:01
Im not really good at VC++ but does anyone have a sample code to get the rotation speed of disk in a computer. I have been working on detecting SSD drives and one solution from researching all day was to get the rotation speed and since SSD have 0 rpm this might be the only way to detect SSD drive. From google wmi ssd detect There is an NV cache manager interface used for ReadyDrive which is new to Vista. I think it is testing NV_FEATURE_PARAMETER's NVReadSpeed and NVWrtSpeed values. Windows 7 detects SSDs by using ATA8-ACS identify word 217: Nominal media rotation rate, with value 0001h as

virtual network interface for windows

守給你的承諾、 提交于 2019-12-05 01:46:04
问题 I'm developing sort of VPN application and need virtual network interface (aka TUN/TAP). Is there any such driver available for windows ? The only one I know of is OpenVPN, but it is GPLed and thus AFAIK can't be used in closed-source app. If there's no ready solution, I'd appreciate some estimation on how complicated is it to code such beast myself (and possibly some direction on where to start). I found this similar question, but it dated back 2008. 回答1: Found this one: wodVPN - claims to

How to set errno in Linux device driver?

一世执手 提交于 2019-12-05 01:37:02
I am designing a Linux character device driver. I want to set errno when error occurs in ioctl() system call. long my_own_ioctl(struct file *file, unsigned int req, unsigned long arg) { long ret = 0; BOOL isErr = FALSE; // some operation // ... if (isErr) { // set errno // ... <--- What should I do? ret = -1; } return ret; } What should I do to achieve that? Thank you at advance! Please allow me to explain my application with more detail. My device is located in /dev/myCharDev. My user space application is like this: #define _COMMAND (1) #define _ERROR_COMMAND_PARAMETER (-1) int main() { int

In Linux, how do you use device_create within an existing class?

情到浓时终转凉″ 提交于 2019-12-04 23:51:49
Note: I'm listing this problem as it is today, I'm not opposed to changing the implementation (moving the creation of the class to a common area for example) if it makes things easier... I'm just not sure how to do it. :End Note I've got two linux kernel modules and I'm trying to update the /sys entries for them. Searching around on google and other sources, I've seen lots of code along the lines of: static dev_t MyDev; static struct class *c1; static int __init start_func(void) { ... MyDev = MKDEV(nMajor, MINOR_VERSION); register_chrdev_region(MyDev, 1, MODULE_NAME); c1 = class_create(THIS

Device driver API match error

天涯浪子 提交于 2019-12-04 22:33:30
I've installed cyanogenmod on my galaxy 3. When developing in Eclipse, most apps seem to work okay. However, I've written an app that needs to access the gallery and every time I try to access it the app crashes with this at log cat: 02-03 19:05:42.054: D/libEGL(10279): loaded /system/lib/egl/libEGL_mali.so 02-03 19:05:42.059: D/libEGL(10279): loaded /system/lib/egl/libGLESv1_CM_mali.so 02-03 19:05:42.059: D/libEGL(10279): loaded /system/lib/egl/libGLESv2_mali.so 02-03 19:05:42.064: E/(10279): Device driver API match 02-03 19:05:42.064: E/(10279): Device driver API version: 23 02-03 19:05:42

Proper way to access registers in a PCI configuration space

冷暖自知 提交于 2019-12-04 15:03:40
When you need to access registers in the PCI configuration space, do you simply need to used built-in BIOS functions to read/write DWORDs into the configuration space? For example, if I am trying to use an IDE controller that is on B0:D31:F1 do I proceed to read/write the configuration register using that BDF as the parameters to the BIOS functions? So if I wanted to get the vendor id I would read the first DWORD in a given BDF? Or am I just way off base? EDIT: In the PCI BIOS specification, I have been looking over the definitions of the BIOS functions for reading and writing words into the

Where can I get Windows checked build?

拥有回忆 提交于 2019-12-04 14:02:06
I'm developing a file system driver. I use free build Windows as a target machine. If I could get a checked build of Windows, I think I get more convenient. Isn't it. But I do not know even where I can get it. Does it need a cost? And what are the benefits I can get, when I use it. Checked builds are available to MSDN subscribers from the MSDN download website. The benefits are that when you attach a kernel debugger to debug your driver, you will gets lots of extra debugging information sent to the debug console, especially if you call any function with invalid parameters, it will be caught

Setting up eclipse for windows driver development

谁都会走 提交于 2019-12-04 12:54:19
I am trying to write a user-mode windows(XP, Vista & 7) virtual printer driver using WDK 7.1.0 . I plan to use eclipse IDE for development, so wanted to know if I can set it up for the same. I am looking to do following:- 1) Eclipse to recognize win32 apis (C and C++) and hence provide features like autocompletion for its function names 2) Eclipse to use compiler provided with WDK 3) Debug the code through eclipse (Not sure if this is possible or not) OR would you suggest some other development environment for windows driver development ? Definitely you should use MS Visual Studio with

about /proc read and write functions

风流意气都作罢 提交于 2019-12-04 06:37:40
问题 I have written a module to read and write from /proc file. the code is showing warnings as commented and shown after the code.the code is as follows: #include<linux/module.h> #include<linux/init.h> #include<linux/proc_fs.h> #include<asm/uaccess.h> #define proc_fs_max 1024 #define proc_entry "my_test" static struct proc_dir_entry *our_proc_file; static char procfs_buffer[proc_fs_max]; static int proc_buffer_size = 0; int proc_read(char *buffer,char **buffer_location,off_t offset,int buffer

When do you use container_of macro?

混江龙づ霸主 提交于 2019-12-04 04:58:16
问题 I know what the macro does. In many kernel level codes, it is often used to traverse linked-list. I want to find other useful cases. When do you use container_of or CONTAINING_RECORD macro? When is the macro extremely useful? 回答1: container_of allows you to simplify your data structures by omitting pointers to parent structures. It's used within the linked list implementation so that the list node can be an element of any structure, and anyone can find the parent structure without carrying