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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:ac8:470e:: with SMTP id f14mr7018783qtp.87.1587692201925; Thu, 23 Apr 2020 18:36:41 -0700 (PDT) X-Received: by 2002:aca:a845:: with SMTP id r66mr5162431oie.44.1587692201148; Thu, 23 Apr 2020 18:36:41 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 23 Apr 2020 18:36:40 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=70.109.61.2; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 70.109.61.2 References: <177496b2-378f-483e-aa67-4b221a531fc6@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7629b797-b205-47cb-8387-199ca0de8464@googlegroups.com> Subject: Re: How to emulate multiple exports From: Jere Injection-Date: Fri, 24 Apr 2020 01:36:41 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:58482 Date: 2020-04-23T18:36:40-07:00 List-Id: On Tuesday, April 21, 2020 at 3:58:24 AM UTC-4, Simon Wright wrote: > Jere writes: > > > On Monday, April 20, 2020 at 5:57:06 AM UTC-4, Simon Wright wrote: > >> Jere writes: > >> > >> > I am working in a space constrained environment (256k flash) > >> > and I want to try and reuse the same exported function for > >> > all of my unused interrupt handlers. > >> > >> I don't know if it'll help, but I handle a similar problem in Cortex > >> GNAT RTS starting here: > >> > >> https://github.com/simonjwright/cortex-gnat-rts/blob/master/stm32f4/adainclude/startup.adb#L147 > > > > That looks closer to what I was trying. Out of curiosity, how > > does it handle someone wanting to later on assign a specific > > peripheral ISR (like a timer for example)? It looks like > > all the remaining ISR slots use the same external > > symbol (IRQ_Handler) > > It doesn't. Of course it could (write to the interrupt vector & set the > hardware interrupt priority in NVIC), but you wouldn't then be able to > use a protected handler. I don't think you'd want to? the reason for > having a specific handler would be for performance, e.g. drone motor > electronic speed control. In my scenario, I'm working with a ZFP runtime, so I don't have access to protected types. I don't think I can leverage the attach handler method? What I currently have is an array of weak references so that client code can export a procedure using that symbol name to add their handlers. I don't like this though as I haven't found a good way to default those handlers, which I feel is pretty unsafe. If they enable an interrupt without a handler it might just jump into the wind. I could do it with a C file, but I am struggling to keep this as much Ada as possible. Performance on ISRs is a concern. I'm running at 4MHz, so about 250ns per instruction cycle and I interface with some things that need on the order of 10us response time (infrequently, but when it happens, the performance needs to be there). Otherwise, I might just use an indirect jump to another memory location and manage my ISR's there (similar to how a primitive bootloader might handle an IVT).