LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-07-2007, 02:03 PM   #1
MattFunke
LQ Newbie
 
Registered: Mar 2006
Distribution: TSLinux 3.0, RedHat Enterprise 4
Posts: 16

Rep: Reputation: 0
Functions #included don't want to behave


I tried #include-ing asm/io.h so that I could use writew(). No joy.

I tried #include-ing linux/sched.h so that I could use request_irq(). It seems that gcc doesn't like that, either.

I have no idea what to try so that I can use these functions. I'm using gcc version 2.95.3. Here's the macro that defines writew() in asm/io.h:

#define writew(b,addr) (*(volatile unsigned short) __io_virt(addr) = (b))

... and here's the function call:

writew(WDT_EN_KEYSEQ1,(unsigned long)(wdtmrctl));

WDT_EN_KEYSEQ1 is previously #defined to be 0x3333, and wdtmrctl is an unsigned long.

Here's the function prototype for request_irq() in linux/sched.h:

extern int request_irq(unsigned int, void (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *dev_name, void *dev_id);

... and here's the function call:

request_irq(SOFTWARE_WATCHDOG_IRQ, watchdog_interrupt_handler, SA_SAMPLE_RANDOM, WATCHDOG_DEVNAME, NULL);

SOFTWARE_WATCHDOG_IRQ is #defined to be 13 (an interrupt known to be free on the system), watchdog_interrupt_handler is a function that should be run when the interrupt is tripped, SA_SAMPLE_RANDOM is a permissible flag, and WATCHDOG_DEVNAME is #defined to be "sc520_wdt".

Any ideas -- hints, clues, anything -- at all about what I'm getting wrong?
 
Old 11-07-2007, 04:50 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
To use those functions you need to be programming the kernel or a kernel module. Are you aware of that and what it takes to compile/link kernel (module) sources? (if you do, sorry I asked, but it wasn't clear)

How did you compile and link you kernel module source file(s)?
 
Old 11-08-2007, 07:04 AM   #3
MattFunke
LQ Newbie
 
Registered: Mar 2006
Distribution: TSLinux 3.0, RedHat Enterprise 4
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Hko View Post
To use those functions you need to be programming the kernel or a kernel module. Are you aware of that and what it takes to compile/link kernel (module) sources?
Wow. I guess not. I just tried to send it through gcc. Can you give me a pointer to where I can look to find out how that's properly done?
 
Old 11-10-2007, 12:59 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by MattFunke View Post
Wow. I guess not. I just tried to send it through gcc. Can you give me a pointer to where I can look to find out how that's properly done?
Here's one: http://tldp.org/LDP/lkmpg/2.6/html/index.html

But if you were not aware that that is what you were doing, I would recommend you stick to programming normal executable using the the glibc API.

Fiddling with the kernel's IRQ's is not for even advanced programmers IMHO.

Last edited by Hko; 11-10-2007 at 01:05 PM. Reason: fixed th link
 
Old 11-12-2007, 09:14 AM   #5
MattFunke
LQ Newbie
 
Registered: Mar 2006
Distribution: TSLinux 3.0, RedHat Enterprise 4
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Hko View Post
But if you were not aware that that is what you were doing, I would recommend you stick to programming normal executable using the the glibc API.

Fiddling with the kernel's IRQ's is not for even advanced programmers IMHO.
I appreciate the warning, but I'm trying to develop this stuff for a single-board computer. Replacing the entire file system is as simple as taking out the old compact flash card and inserting another with a clean Linux install image on it. If Bad Things Happen, there's a little bit of a safety net for me while I learn, since I won't be hosing my main computer.

Thanks for the pointer to the HOWTO site! That will likely be quite valuable during my learning process.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: OpenOffice.org Calc functions, part 1: Understanding functions LXer Syndicated Linux News 0 03-31-2007 12:01 PM
How: altgr to behave like alt JussiKp Linux - General 0 12-02-2006 11:50 AM
mc doesn't behave in Konsole will103 Linux - Software 0 10-03-2004 10:41 AM
Can I make 'cd' behave this way? exitsfunnel Linux - Software 4 08-30-2003 05:57 PM
VI dosnt behave .... phoeniXflame Linux - Software 7 06-22-2003 11:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration