Writing a driver.

This is a discussion on Writing a driver. within the C Programming forums, part of the General Programming Boards category; I wanna try writing a driver in C and I need some help. Well, I know that the standard I/O ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    242

    Writing a driver.

    I wanna try writing a driver in C and I need some help.
    Well, I know that the standard I/O can be done with output and inport functions but I really have no idea what arguments to pass, and that's it basically so I would like to have your help.
    If you have built a driver, please post links that helped you writing this driver, or post your driver here.
    I also would like you to give me ideas of different drivers to write.
    Thanks.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I've never written a driver, but here are a couple links I found on Google:
    How to Write a Windows Driver
    Writing a Linux Driver

    As for an idea of a driver to write, how about writing a Linux RAID driver for my ASUS P5K3 Deluxe motherboard? Windows can see the RAID configuration from the BIOS, but Linux just sees 3 separate HDs. And no, I won't volunteer to be a beta tester for it.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    Search for "DDK" and the name of whatever OS you're using.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,182
    Writing a driver is a ... difficult task. Are you sure you're up for it? You haven't exactly made the best impression with your knowledge of C.
    But if you are willing, I can suggest that you use a virtual machine as your test platform because if your driver screws up... well, then you're going to crash your operating system, most likely. And cause other bad effects.

    Good luck.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    Quote Originally Posted by Elysia View Post
    Writing a driver is a ... difficult task. Are you sure you're up for it? You haven't exactly made the best impression with your knowledge of C.
    But if you are willing, I can suggest that you use a virtual machine as your test platform because if your driver screws up... well, then you're going to crash your operating system, most likely. And cause other bad effects.

    Good luck.
    Actually I was thinking of plugging a led to a USB and turn the lights on and off so I don't think it would be difficult enough.
    Anyways, do you have another good task that could improve my C skills?

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,182
    Quote Originally Posted by eXeCuTeR View Post
    Actually I was thinking of plugging a led to a USB and turn the lights on and off so I don't think it would be difficult enough.
    While that sounds basic, I don't think writing a driver for it is trivial, because drivers are difficult...

    Anyways, do you have another good task that could improve my C skills?
    I don't know how much you know and such, but there have been questions about exercises before... Why not do a search of the board? I'm sure you'll find something.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  7. #7
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    Ever tried DDK in Windows?

    Someone use it to monitor Process events, in this case for API hijacking (monitoring and fowarding) somewhere in CodeProject.

    The source code looks complicated, and I've failed to find the reference, but maybe it's a good start.
    Last edited by audinue; 07-05-2008 at 01:32 PM.

  8. #8
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Here's one good one for Windows:

    http://www.codeproject.com/KB/system/driverdev.aspx

  9. #9
    Registered User
    Join Date
    Jul 2008
    Posts
    26
    Quote Originally Posted by eXeCuTeR View Post
    Actually I was thinking of plugging a led to a USB and turn the lights on and off so I don't think it would be difficult enough.
    How are you planning on doing that? I'm going to assume you don't know embedded c programming that well, so you'll most likely be using a usb development board. In which case, drivers will be written for you.

    You can't use the output and inport functions with usb. To turn a LED on/off via usb typically takes a few hundred lines of usb code on both the PC and the board controlling the LED.

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    With archaic serial and parallel ports, you could just strap an LED across a couple of pins, and to make it light up, all you would need is a couple of outport() instructions and you'd be good.

    But USB is much more complex than that!
    There's a whole series of steps which need to take place when you first plug a USB device into your machine (it's what makes all this plug-and-play work).

    For USB hardware you can play about with, consider something like this (from your local supplier)
    http://www.maplin.co.uk/module.aspx?...=42857&doy=6m7

    Then read pretty much everything here - http://www.lvr.com/
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    Quote Originally Posted by Mole42 View Post
    How are you planning on doing that? I'm going to assume you don't know embedded c programming that well, so you'll most likely be using a usb development board. In which case, drivers will be written for you.

    You can't use the output and inport functions with usb. To turn a LED on/off via usb typically takes a few hundred lines of usb code on both the PC and the board controlling the LED.
    http://www.linuxjournal.com/article/7353
    I haven't read it yet but it seems to be what I'm looking for.

  12. #12
    Registered User
    Join Date
    Jul 2008
    Posts
    26
    Simple usb device coupled with example usb driver code.

    I'd say go for it, if your OS is Linux of course.

  13. #13
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > I'd say go for it, if your OS is Linux of course.
    That really doesn't make a difference...

  14. #14
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    Here is a link for a free online book. This gives you complete information about the device driver if your working linux platform.

    http://www.xml.com/ldd/chapter/book/

    ssharish

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get started with writing driver in Linux?
    By Maz in forum C Programming
    Replies: 1
    Last Post: 04-21-2009, 09:10 AM
  2. Writing a linux hardware driver
    By nexusone in forum Linux Programming
    Replies: 1
    Last Post: 08-12-2008, 07:33 PM
  3. Writing a driver...
    By Devil Panther in forum C Programming
    Replies: 4
    Last Post: 06-30-2005, 07:55 AM
  4. Driver writing for windows
    By BrownB in forum C Programming
    Replies: 1
    Last Post: 10-31-2003, 06:14 AM
  5. writing device driver
    By ronin in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 07-08-2002, 10:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21