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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.112.231 with SMTP id it7mr7959813obb.22.1392558011826; Sun, 16 Feb 2014 05:40:11 -0800 (PST) X-Received: by 10.140.80.47 with SMTP id b44mr1266qgd.33.1392558011798; Sun, 16 Feb 2014 05:40:11 -0800 (PST) Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!uq10no23440285igb.0!news-out.google.com!dr7ni182qab.1!nntp.google.com!f11no21548509qae.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 16 Feb 2014 05:40:11 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=201.95.3.197; posting-account=TRgI1QoAAABSsYi-ox3Pi6N-JEKKU0cu NNTP-Posting-Host: 201.95.3.197 References: <215f6df2-a7ec-42f4-ac82-656d5b12bf61@googlegroups.com> <8383f5d6-3f66-415b-ab3f-8801fa377a6b@googlegroups.com> <8200939f-9bbd-44dd-848c-00c663f37121@googlegroups.com> <1e41e2d6-7ff8-445d-9c14-14c49b244bcf@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Best representation for spares From: "Rego, P." Injection-Date: Sun, 16 Feb 2014 13:40:11 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Original-Bytes: 4616 Xref: number.nntp.dca.giganews.com comp.lang.ada:184910 Date: 2014-02-16T05:40:11-08:00 List-Id: On Sunday, February 16, 2014 7:02:41 AM UTC-3, Niklas Holsti wrote: > Here you are "overlaying" a record object on a specific storage > location, presumably a memory-mapped I/O control register. This is OK, > but it has consequences... But is there a diffferent way to memory-map the registers? > The compiler is warning you that the initialization of the Spare > component will take place during the elaboration of the declaration of > Auxiliary_Peripherals_Register_Map, which is usually not what one wants > to happen with memory-mapped I/O registers. Usually, such registers are > initialized by explicit assignment statements later on, in the system > initialization procedure. Yes, I was thinking about it. I think it's better to not initialize the spares in the type definition and include this in the system initialization. You are right. > > But in this case I do not want to suppress initialization. > Why not? If the Spare bits are documented as "reserved", there should > not be any need to initialize just them, and your record type (the one > that is declared in the quote) does not default-initialize any other > components, which means that the default initialization gives them some > garbage values. Or leaves them unchanged, if it can write only to the > Spare bits (unlikely, and partial-word access to mmio registers is > usually not desirable anyway -- look into using the Atomic aspect for > such objects). There are some points in datasheet which are a little confusing, it says the spare is "reserved", but also says "write zero" in some cases (not all). > > What to do to eliminate this warning? > You can suppy an explicit initialization in the object declaration, even > one using the default initial values for all components: > Auxiliary_Peripherals_Register_Map: > Auxiliary_Peripherals_Register_Map_Type > := (others => <>); > -- ^^^^^^^^^^^^^^^^^^ > -- Explicit initialization using default initial values. Ok Fine. > for Auxiliary_Peripherals_Register_Map'Address use > System'To_Address (16#7E21_5000#); > However, this assigns *unknown* values to the components without default > initial values, that is, the xxx_IRQ components. You probably want to > initialize these components to False, to avoid spurious invocation of > the interrupt handlers. > I would not put any default initializations in record types that I > intend to overlay onto mmio registers. I did not get. Is is better to use Auxiliary_Peripherals_Register_Map: Auxiliary_Peripherals_Register_Map_Type := (others => <>); or just initialize in system initialization? (or both?) > That is a default initialization. As the RM says, if the object is > imported, the default initialization is not done, just as if you had > declared the component without it, as > Spare : Zero_Bits (3 .. 31); > Moreover, the RM section you quote makes it illegal to give an explicit > initialization (as in my example above) for an imported object. Thus, to > "initialize" an imported object, you must use an ordinary assignment > statement. The declaration of an imported object cannot initialize it. Ok. -- Regards, Rego.