LinuxQuestions.org
Help answer threads with 0 replies.
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 12-04-2004, 09:11 PM   #1
azrail1222
LQ Newbie
 
Registered: Jun 2004
Location: Princeton, New Jersey
Posts: 7

Rep: Reputation: 0
Help Porting i386_get_ioperm


I have a few lines of code that is in dammit (http://www.csh.rit.edu/projects/dammit/) and I am not a BSD person at all. So I am looking for anyone to help port the following lines of code to linux.

Code:
   #define BPL (sizeof(u_long) * 8)
   int port = 0x378;
   u_long iom[32];

   if(i386_get_ioperm(iom) == -1) {
        perror("get_ioperm");
        return 1;
    }
    iom[port / BPL] ^= (1 << (port % BPL));
    if(i386_set_ioperm(iom) == -1) {
        perror("set_ioperm");
        return 1;
    }
 
Old 12-05-2004, 01:36 AM   #2
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Rep: Reputation: 15
look at the following example:
----------------------------------------------------------------------------------------------------------
/*
* example.c: very simple example of port I/O
*
* This code does nothing useful, just a port write, a pause,
* and a port read. Compile with `gcc -O2 -o example example.c',
* and run as root with `./example'.
*/

#include <stdio.h>
#include <unistd.h>
#include <sys/io.h>
#include <stdlib.h>



#define BASEPORT 0x378 /* lp1 */

int main()
{
/* Get access to the ports */
if (ioperm(BASEPORT, 2, 1)) {perror("ioperm"); exit(1);}

/* Set the data signals (D0-7) of the port to all low (0) */
outb(100, BASEPORT);

/* Sleep for a while (100 ms) */
usleep(100000);

/* Read from the status port (BASE+1) and display the result */
printf("status: %d\n", inb(BASEPORT ));

/* We don't need the ports anymore */
if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);}

exit(0);
}

/* end of example.c */
 
Old 12-05-2004, 01:39 AM   #3
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Rep: Reputation: 15
By the way I am looking for a similar thing to ioperm, but for port that ioperm does not support.
If You know how can I write directly to an adress that I know in C or assembler, please contact with me.
Thanks
 
Old 12-05-2004, 02:04 AM   #4
azrail1222
LQ Newbie
 
Registered: Jun 2004
Location: Princeton, New Jersey
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks leonidg, but I am not sure if that is what I am looking for because I don't see where you are able to read the current state of the port. Then edit, and resore it with the code you provided.
 
Old 12-05-2004, 02:11 AM   #5
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Rep: Reputation: 15
function inb(PORT) returns the current state of the port and outb(...,port) edits it
 
  


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
Porting on request. gcclinux JDS 0 06-27-2005 06:18 AM
Porting question kwt0 Linux - Software 1 05-25-2005 12:50 PM
HP-UX to linux porting arunprakash Other *NIX 2 03-01-2005 10:53 PM
Porting C++ from HP-UX 11.0 to Linux paul sachs Other *NIX 2 01-10-2005 05:37 PM
cygwin porting Vader Linux - Software 1 01-01-2004 07:02 AM

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

All times are GMT -5. The time now is 12:25 PM.

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