All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] user space interrupt
@ 2006-12-08 14:01 mani bhatti
  2006-12-08 16:50 ` Gilles Chanteperdrix
  2006-12-16 17:10 ` Hannes Mayer
  0 siblings, 2 replies; 7+ messages in thread
From: mani bhatti @ 2006-12-08 14:01 UTC (permalink / raw)
  To: xenomai


[-- Attachment #1.1: Type: text/plain, Size: 666 bytes --]

Hi all 
i am trying to access parallel port form a user space task.i have copied code from an example which runs parallel port in interrupt mode but the problem is that when i run program i get following message 

"iopl err"

due to this piece of  code 
        
// ask for permission to access the parallel port from user-space
        if (iopl(3)) {
                printf("iopl err\n");
                exit(1);
        }


i am working with interrupts for the first time and have no idea why this is happening .i am attaching the code also.Thanks all for the great help.

 
---------------------------------
Everyone is raving about the all-new Yahoo! Mail beta.

[-- Attachment #1.2: Type: text/html, Size: 1049 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 4248410318-doppel_task.c --]
[-- Type: text/x-csrc; name="doppel_task.c", Size: 2440 bytes --]


#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/io.h>
#include <sys/mman.h>

#include <native/task.h>
#include <native/queue.h>
#include <native/intr.h>



#define STACK_SIZE 8192
#define STD_PRIO1 2
#define STD_PRIO2 1
#define IRQ_NUMBER 7 
#define BASEPORT 0x378
#define PARPORTINT 7


RT_TASK zaehler1_task_ptr;
RT_TASK zaehler2_task_ptr;
RT_INTR intr_desc;

int count1 = 0;
int count2 = 0;
int i;
int end = 0;

//                      --s-ms-us-ns
RTIME task_period_ns1 =   1000000000llu;
RTIME task_period_ns2 =  10000000000llu;




void zaehler2_task(void *cookie){
	int ret;	
	long ii;
	long jj;
	double a;
        unsigned long overrun;
        int err;



// ********************** Beginn des wiederholt ausgefuehrten Codes **********************************************
	while(!end){
	
         err = rt_intr_wait(&intr_desc,TM_INFINITE);
         printf("Error is %d\n",err);

                printf("\nInterrupt occured");

		fflush(NULL);
        }
// ********************** Ende des wiederholt ausgefuehrten Codes ***********************************************
}
       


// signal-handler, to ensure clean exit on Ctrl-C
void clean_exit(int dummy) {
	printf("cleanup\n");
	end = 1;

	rt_task_delete(&zaehler2_task_ptr);
	printf("end\n");
}

int main(int argc, char *argv[]) {
	int err, ret;
	printf("start\n");
	// install signal handler
	signal(SIGTERM, clean_exit);	
	signal(SIGINT, clean_exit);	
	
        // ask for permission to access the parallel port from user-space
	if (iopl(3)) {  
		printf("iopl err\n");
		exit(1);
	}


         outb_p(0x10, BASEPORT + 2);
         err = rt_intr_create(&intr_desc,"MyIrq",IRQ_NUMBER,NULL);
         printf("rt_intr_create=%i\n", err);

         switch(-err)

          {
             case ENOMEM  :
             printf("fail to allocate dynamic memory");
             break;

             case EBUSY:
             printf("Busy");
             break;
             }

        rt_intr_enable (&intr_desc);


   


          mlockall(MCL_CURRENT|MCL_FUTURE);
  
       
                   


	/* create zaehler2_task */
//	err = rt_task_create(&zaehler2_task_ptr,"beta",STACK_SIZE,STD_PRIO2,0);


	/* start zaehler2_task */
//	err = rt_task_start(&zaehler2_task_ptr,&zaehler2_task,NULL);

	// wait for signal & return of signal handler
	pause();
	fflush(NULL);
	return 0;
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] user space interrupt
  2006-12-08 14:01 [Xenomai-help] user space interrupt mani bhatti
@ 2006-12-08 16:50 ` Gilles Chanteperdrix
  2006-12-14 16:27   ` mani bhatti
  2006-12-16 17:10 ` Hannes Mayer
  1 sibling, 1 reply; 7+ messages in thread
From: Gilles Chanteperdrix @ 2006-12-08 16:50 UTC (permalink / raw)
  To: mani bhatti; +Cc: xenomai

mani bhatti wrote:
> Hi all
> i am trying to access parallel port form a user space task.i have copied
> code from an example which runs parallel port in interrupt mode but the
> problem is that when i run program i get following message
> 
> "iopl err"
> 
> due to this piece of  code
>        
> // ask for permission to access the parallel port from user-space
>         if (iopl(3)) {
>                 printf("iopl err\n");
>                 exit(1);
>         }
> 
> 
> i am working with interrupts for the first time and have no idea why
> this is happening .i am attaching the code also.Thanks all for the great
> help.

What is the error message if you replace printf("iopl err\n") with
perror("iopl") ?

-- 
                                                 Gilles Chanteperdrix


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] user space interrupt
  2006-12-08 16:50 ` Gilles Chanteperdrix
@ 2006-12-14 16:27   ` mani bhatti
  2006-12-14 16:32     ` Gilles Chanteperdrix
  0 siblings, 1 reply; 7+ messages in thread
From: mani bhatti @ 2006-12-14 16:27 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

[-- Attachment #1: Type: text/plain, Size: 1179 bytes --]

Hi Gilles and all
 Thanks for ur help.The error i get after replacing printf with 
 perror("iopl") is "iopl: Operation not permitted".
 Please suggest me some solution for this.Thanks again.

Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: mani bhatti wrote:
> Hi all
> i am trying to access parallel port form a user space task.i have copied
> code from an example which runs parallel port in interrupt mode but the
> problem is that when i run program i get following message
> 
> "iopl err"
> 
> due to this piece of  code
>        
> // ask for permission to access the parallel port from user-space
>         if (iopl(3)) {
>                 printf("iopl err\n");
>                 exit(1);
>         }
> 
> 
> i am working with interrupts for the first time and have no idea why
> this is happening .i am attaching the code also.Thanks all for the great
> help.

What is the error message if you replace printf("iopl err\n") with
perror("iopl") ?

-- 
                                                 Gilles Chanteperdrix


 
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your question on Yahoo! Answers.

[-- Attachment #2: Type: text/html, Size: 1602 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] user space interrupt
  2006-12-14 16:27   ` mani bhatti
@ 2006-12-14 16:32     ` Gilles Chanteperdrix
  2006-12-15 14:59       ` mani bhatti
  0 siblings, 1 reply; 7+ messages in thread
From: Gilles Chanteperdrix @ 2006-12-14 16:32 UTC (permalink / raw)
  To: mani bhatti; +Cc: xenomai

mani bhatti wrote:
> Hi Gilles and all
> Thanks for ur help.The error i get after replacing printf with
> perror("iopl") is "iopl: Operation not permitted".
> Please suggest me some solution for this.Thanks again.

"Operation not permitted" is the error message for the error code EPERM.
Now look for EPERM in iopl manual page.

-- 
                                                 Gilles Chanteperdrix


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] user space interrupt
  2006-12-14 16:32     ` Gilles Chanteperdrix
@ 2006-12-15 14:59       ` mani bhatti
  2006-12-15 18:18         ` Gilles Chanteperdrix
  0 siblings, 1 reply; 7+ messages in thread
From: mani bhatti @ 2006-12-15 14:59 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai


[-- Attachment #1.1: Type: text/plain, Size: 958 bytes --]

Thanks a lot
The error with "iopl" is fixed after i have acquired the root right but now problem is that rt_intr_create(&intr_desc,"MyIrq",IRQ_NUMBER,I_NOAUTOENA);

returns -22 which i dont understand  what it means.my code is extremely simple  .i have attached the code also please guide me how can i solve this problem.thanks again.

Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: mani bhatti wrote:
> Hi Gilles and all
> Thanks for ur help.The error i get after replacing printf with
> perror("iopl") is "iopl: Operation not permitted".
> Please suggest me some solution for this.Thanks again.

"Operation not permitted" is the error message for the error code EPERM.
Now look for EPERM in iopl manual page.

-- 
                                                 Gilles Chanteperdrix


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[-- Attachment #1.2: Type: text/html, Size: 1197 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 18037014-parinterrupt.c --]
[-- Type: text/x-csrc; name="parinterrupt.c", Size: 2367 bytes --]


#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/io.h>
#include <sys/mman.h>

#include <native/task.h>
#include <native/queue.h>
#include <native/intr.h>



#define STACK_SIZE 8192
#define STD_PRIO1 2
#define STD_PRIO2 1
#define IRQ_NUMBER 7 
#define BASEPORT 0x378
#define PARPORTINT 7


RT_TASK zaehler1_task_ptr;
RT_TASK zaehler2_task_ptr;
RT_INTR intr_desc;

int count1 = 0;
int count2 = 0;
int i;
int end = 0;

//                      --s-ms-us-ns
RTIME task_period_ns1 =   1000000000llu;
RTIME task_period_ns2 =  10000000000llu;


void zaehler2_task(void *cookie){
	int ret;	
	long ii;
	long jj;
	double a;
        unsigned long overrun;
        int err;

	while(!end){
	
         err = rt_intr_wait(&intr_desc,TM_INFINITE);
         printf("Error is %d\n",err);

                printf("\nInterrupt occured");

		fflush(NULL);
        }
// ********************** Ende des wiederholt ausgefuehrten Codes ***********************************************
}
       


// signal-handler, to ensure clean exit on Ctrl-C
void clean_exit(int dummy) {
	printf("cleanup\n");
	end = 1;
	rt_task_delete(&zaehler2_task_ptr);
        rt_intr_delete(&intr_desc);	
        printf("end\n");
}

int main(int argc, char *argv[]) {
	int err, ret;
	printf("start\n");
	// install signal handler
	signal(SIGTERM, clean_exit);	
	signal(SIGINT, clean_exit);	
	
        // ask for permission to access the parallel port from user-space
	if (iopl(3)) {  
	      perror("iopl"); 
          //	printf("iopl err\n");
		exit(1);
	}


         outb_p(0x10, BASEPORT + 2);
         mlockall(MCL_CURRENT | MCL_FUTURE);
         err = rt_intr_create(&intr_desc,"MyIrq",IRQ_NUMBER,I_NOAUTOENA);
         printf("rt_intr_create=%i\n", err);

         switch(-err)

          {
             case ENOMEM  :
             printf("fail to allocate dynamic memory");
             break;

             case EBUSY:
             printf("Busy");
             break;
             }

        rt_intr_enable (&intr_desc);
   


	/* create zaehler2_task */
	err = rt_task_create(&zaehler2_task_ptr,"beta",STACK_SIZE,STD_PRIO2,0);

	/* start zaehler2_task */
	err = rt_task_start(&zaehler2_task_ptr,&zaehler2_task,NULL);

	// wait for signal & return of signal handler
	pause();
	fflush(NULL);
	return 0;
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] user space interrupt
  2006-12-15 14:59       ` mani bhatti
@ 2006-12-15 18:18         ` Gilles Chanteperdrix
  0 siblings, 0 replies; 7+ messages in thread
From: Gilles Chanteperdrix @ 2006-12-15 18:18 UTC (permalink / raw)
  To: mani bhatti; +Cc: xenomai

mani bhatti wrote:
> Thanks a lot
> The error with "iopl" is fixed after i have acquired the root right but
> now problem is that
> rt_intr_create(&intr_desc,"MyIrq",IRQ_NUMBER,I_NOAUTOENA);
> 
> returns -22 which i dont understand  what it means.my code is extremely
> simple  .i have attached the code also please guide me how can i solve
> this problem.thanks again.

-22 is -EINVAL. It is not documented, but if you look at the code, you
will see that it may happen if the mode is invalid. I_NOAUTOENA should
be a valid mode, so I have no idea of what may be wrong.

-- 
                                                 Gilles Chanteperdrix


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] user space interrupt
  2006-12-08 14:01 [Xenomai-help] user space interrupt mani bhatti
  2006-12-08 16:50 ` Gilles Chanteperdrix
@ 2006-12-16 17:10 ` Hannes Mayer
  1 sibling, 0 replies; 7+ messages in thread
From: Hannes Mayer @ 2006-12-16 17:10 UTC (permalink / raw)
  To: mani bhatti; +Cc: xenomai

mani bhatti wrote:
> Hi all
> i am trying to access parallel port form a user space task.i have copied 
> code from an example which runs parallel port in interrupt mode but the 
> problem is that when i run program i get following message
> 
> "iopl err"
> 
> due to this piece of  code
>        
> // ask for permission to access the parallel port from user-space
>         if (iopl(3)) {
>                 printf("iopl err\n");
>                 exit(1);
>         }
> 

Have a look here:
http://www.captain.at/xenomai-parallel-port-interrupt.php

Ciao,
Hannes.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-12-16 17:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-08 14:01 [Xenomai-help] user space interrupt mani bhatti
2006-12-08 16:50 ` Gilles Chanteperdrix
2006-12-14 16:27   ` mani bhatti
2006-12-14 16:32     ` Gilles Chanteperdrix
2006-12-15 14:59       ` mani bhatti
2006-12-15 18:18         ` Gilles Chanteperdrix
2006-12-16 17:10 ` Hannes Mayer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.