- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm a newbie in Nios, and my English is not to good, but in this forum i found some topics to control NiosII device like pio, timer, uart by Nios syntax, but few topic about to teach me about dma & interrupt, so when i want to control dma & interrupt, i can't do it , and i found in kernel's system.h file didn't have include about this file, now i am so confuse , maybe i am wrong way to control it , so i think maybe it need to use uclinux syntax to control the device , not use nios syntax, but i really don't know what show i do , could anyone can give me some suggests or example to that me know what to do. Thank you.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I haven't tested DMA myself but for IRQ you can just use the linux kernel functions.
With a call to request_irq you can register your Interrupt service routine. Make sure to do this from kernel-space (a kernel module or compiled in the kernel) "normal" userspace programs can't (and shouldn't) recieve IRQ's. Iirc someone on this forum uses the kernel functions for DMA-transfers, maybe you can find the thread. Greetz wgoossens P.S.: Don't worry about your english!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
a little code snippet to play with dma. it works in userspace without an interrupt. This is dirty style and works without Kernel and interrupt. If you understand (read the dma chapter in the pdf about the peripheral) how it works, it will be easy to do this with kernel functions in a driver. You can find the kernel functions in $(KERNEL_PLUGIN)\linux-2.6.x\arch\nios2nommu\kernel\dma.c#define na_dma_0 0x12345678# define inl(addr)
({
unsigned int __res;
__asm__ __volatile__(
"ldwio %0, 0(%1)"
: "=r"(__res)
: "r" (addr));
__res;
})
//-----------------------------------------------------------------------
# define outl(b,addr)
({
__asm__ __volatile__(
"stwio %0, 0(%1)"
: : "r"(b), "r" (addr));
})
void testdma (int source, int dest)
{
outl (0,na_dma_0);
outl (0,na_dma_0+24);
outl (source,na_dma_0+4);
outl (dest,na_dma_0+8);
outl (1472,na_dma_0+12);
outl (0x8c,na_dma_0+24);
while (inl(na_dma_0)==0x2);
}
replace in the snippet 0x12345678 with the address of your dma controller
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for replay, i think i know the way to solve thoses quests, but i wnat include the <linux/sched.h> to run linux kernel function but i can't complier it
because it can't found the autoconf.h file so i can't complier it, maybe i include wrong header file ,so i want to knwo if i want to use interrupt & dma llinux kernel function what header files should i include? can help me ? thanks..- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you want to write a driver?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think i'm not to write a driver, i just want to use this like use nios syntax.
For example, in nios i can add some pios , button , timer , dma and use interrupt by my control program , because in nios syntax , it have function to control it, but in nios uclinux , i also can add what i wnat in sopc builder and to control it by nios syntax , but just ISR and dma i can't use nios syntax to control , i just want to know how can i to control interrupt & dma function (pio isr, timer isr, uart isr and dma), i don't know i'm writing a driver now?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well,
i ask this question, because i'm confused. basicly under linux, there a two type of "programs". 1) a normal application: a normal application doesn't access the hardware directly or uses kernel functions. it will use a driver -> system calls (program runs in user-space). if try to access kernel functions from an application i don't know. you might have to trick a lot. you can try to register the interrupt manually without linux (study the altera hal sources). 2) a kernel module ("driver") gets direct access to the hardware and can use kernel function, so i was thinking you are going to write a driver...- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to handle irq or dma on Linux, you are writing drivers or doing module programming in kernel space. You MUST NOT mix HAL and Linux.
Read ch10 about irq and ch15 about dma on the book, " Linux device driver 3rd Ed."- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
TO_BE_DONE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ucliane,
It is great that you read the LDD book. It seems you mixed up the kernel space and user space. Please read LDD from beginning. Another (old) advice, do it on Linux. follow the thread http://forum.niosforum.com/forum/index.php?showtopic=3174 (http://forum.niosforum.com/forum/index.php?showtopic=3174) Then, you should try out the hello world module in ch2 of LDD. Next, take a look at some kernel codes, eg, arch/nios2nommu/kernel/time.c drivers/serial/NIOSserial.c . Finally back to your own code.- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page