From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.168.35 with SMTP id r35mr4799778ioe.25.1498775909826; Thu, 29 Jun 2017 15:38:29 -0700 (PDT) X-Received: by 10.36.69.103 with SMTP id y100mr171685ita.0.1498775909795; Thu, 29 Jun 2017 15:38:29 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!v202no118497itb.0!news-out.google.com!k7ni3734itk.0!nntp.google.com!188no182842itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 29 Jun 2017 15:38:29 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2607:fea8:3ce0:20f:2de9:63f9:413:d1f6; posting-account=cUi90woAAADTaOISowbbHM8GUD0-opJO NNTP-Posting-Host: 2607:fea8:3ce0:20f:2de9:63f9:413:d1f6 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: R/W hardware registers ? From: patrick@spellingbeewinnars.org Injection-Date: Thu, 29 Jun 2017 22:38:29 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:47196 Date: 2017-06-29T15:38:29-07:00 List-Id: Hi Everyone This post is partly a a continuation of this one: https://groups.google.com/forum/#!searchin/comp.lang.ada/ada$20hardware|sor= t:relevance/comp.lang.ada/ZhB27DtPb9I/y7dxjrhZCAAJ There are some really great applications written in C but I try to avoid C = whenever I can. I haven't been able to avoid it over the past few months. There are lots of ways to interact with hardware from a desktop PC but a lo= t of them involve C. Microprocesor, SBCs(like RPI) and microcontroller base= d solutions are probably easier than ever before. There is great work being= done with AVR-Ada but really all I want to do is use a desktop computer wi= th some circuits. I have been fooling around with parallel ports on and off the past few mont= hs. I am thinking about getting an ISA breadboard card and fooling around a= little more. I have other plans but right now it's just some hobby silline= ss. I have been reading about writing Linux device drivers but I just don't nee= d interupts and so on and I am losing interest in reading about this furthe= r. Assuming these: 1)It's just hobby fun 2)I am the only user 3)it's on Posix, normally linux 4)I am interacting with CPU-less, passive circuitry Then do you see any major problems with just reading and writing to a devic= e's registers though root access and without a kernel API? Please see this program, it's cut down to keep it simple: #include #include =20 #include =20 /* Address of the first parallel port. found in BIOS settings. */ #define kDATA_REG (0xec00) /* Base address =3D data register. */ #define kSTAT_REG (kDATA_REG + 1) /* Status register. */ #define kCONT_REG (kDATA_REG + 2) /* Control register. */ int main() { int i; if (ioperm(kDATA_REG, 1, 1)) /* Get permission to access this port= . */ { printf("ioperm(%x) failed.\nYou must be root to execute!\n", kDAT= A_REG); return 1; } if (ioperm(kCONT_REG, 1, 1)) /* Get permission to access this port= . */ { printf("ioperm(%x) failed.\nYou must be root to execute!\n", kDAT= A_REG); return 1; } /* Assume port is already in output mode (bit 5 in control register).= */ for (i =3D 0; i <=3D 9; i++) /* Let the LED(s) blink. */ { outb(i, kDATA_REG); /* All 8 datalines high. */ printf("value sent is %d \n", i) ; sleep(5); } return 0; } The above program does this. If it's just me, do I really need a call to ioperm ? Could I not access registers through access/pointers ? I bet I could have lots of fun with parallel ports, ISA cards and then afte= r that maybe I could write to the registers of a PIC-E cards and have paral= lel to serial conversion done by the OS and I could dump ISA later and cont= rol circuits in a serial manner(I am not sure about this last part at all) Does anyone see a pitfall I am about to fall into ? Thanks for reading-Patrick