How to store data in non-volatile memory from ACPI?

In my KMDF driver I need to store some Device data that will withstand
Windows reinstallation. The data is device specific and calculated time to
time by driver or some application. I don?t know how to exactly implement
it?

One Microsoft spec suggests using ACPI. It says: ?data access can be
performed by calling the IOCTL_ACPI_EVAL_METHOD using _DSM?. There is NO
description available on how to exactly implement that. I don?t know what
to write inside _DSM and specifically how to write the data to non-volatile
memory in I ASL coding. I have some experience in writing small ASL codes
and UEFI code. Any suggestion on how I can implement it?

Another option is using GetVariable() and SetVariable() of UEFI runtime
interface.

I have options of adding UEFI variables and ACPI code to the Platform. Any
suggestion on which one is good, _DSM methods or SetVariable()?

Thanks in Advance.
Jls

On pre-UEFI, BIOS support is a must, it must have the code in the ACPI methods to store this data to NVRAM.

Also note that pre-UEFI the BIOS had only absolutely tiny amount of the NVRAM space.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com
“Anup Das” wrote in message news:xxxxx@ntdev…
In my KMDF driver I need to store some Device data that will withstand Windows reinstallation. The data is device specific and calculated time to time by driver or some application. I don?t know how to exactly implement it?

One Microsoft spec suggests using ACPI. It says: ?data access can be performed by calling the IOCTL_ACPI_EVAL_METHOD using _DSM?. There is NO description available on how to exactly implement that. I don?t know what to write inside _DSM and specifically how to write the data to non-volatile memory in I ASL coding. I have some experience in writing small ASL codes and UEFI code. Any suggestion on how I can implement it?

Another option is using GetVariable() and SetVariable() of UEFI runtime interface.

I have options of adding UEFI variables and ACPI code to the Platform. Any suggestion on which one is good, _DSM methods or SetVariable()?

Thanks in Advance.
Jls

Aside from the RTC/CMOS storage area that has some very limited amount of storage (64 bytes IIRC), I would think that any OTHER non-volatile memory in the system would be very system specific.

Aside form the above, I’m not aware of any way to allow arbitrary drivers or even ASL Methods to store data in a “standard” non-volatile memory area. How would you manage who accessed this memory and what’s stored there? IOW, what would prevent MY driver from overwriting data that YOUR driver would write to such an area.

Better to store stuff on the disk. You have the same problem with how you exclusively allocate the space, but at least there’s a lot more of it.

Peter
OSR

Peter, I agree I should use Disk. But my problem remains same as you rightly said. What options I have to access the Disk from ACPI? I am new to this and looking for a simple solution.

One point I would like to highlight that this is a New Platform design with an ODM. So I have some freedom of implementation. But I am looking for a Standard technology that others have used earlier.

One option came to my mind is ?Custom ACPI Table?. This table will be created in UEFI. I can add 2 methods to read and write to the table in ACPI for my device. And on restart UEFI will reload the last updated table. I have never written such code and the solution is complex. My question now is,? can such solution work??

Shatskih, please add some more description on ?On pre-UEFI, BIOS support is a must?. It is not described what solution you suggest to use.

I agree on ?it must have the code in the ACPI methods to store this data to NVRAM?. But I could find right kind of ACPI Terms to create or access any space in Disk or any kind of non-volatile memory. Is there any standard method to use? I have agreed to use Disk. But still I am lost in how to write the code.

Shatskih, Peter thanks a lot for your reply.

xxxxx@gmail.com wrote:

Peter, I agree I should use Disk. But my problem remains same as you rightly said. What options I have to access the Disk from ACPI? I am new to this and looking for a simple solution.

I thought the point was to use disk INSTEAD of ACPI/UEFI magic. Weren’t
you just looking for a way for the driver to store information that
would survive a reinstall? You’d read and write it from your driver,
not from the BIOS. You wouldn’t survive a reformat, of course, but
that would be an issue with your concept, too.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> Shatskih, please add some more description on ?On pre-UEFI, BIOS support is a must

Your BIOS must be aware of this device, and must provide some special NVRAM cells to store this information.

BTW - persisting any information (with the exception of some serious crypto stuff) in the computer across disk wipes is just a moronic idea. Users and admins DO expect the whole computer to be reset to its original state after this. Messing with natural user expectations is moronic.

So, garbage in (requirements), garbage out (implementation ideas).

Some devices like TPM crypto really have the serious requirements on keeping some data inside across disk wipe. But they have some amount of flash NVRAM inside themselves. This is the best possible way to go.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

I tried to get the industry to make a standard interface to CMOS settings once. Nobody really cared enough to do it.

(And modern RTC/CMOS devices usually have more than 64 bytes of space these days, but the interface to get to the extended space tends to differ from part to part.)

  • Jake Oshins
    (former HAL guy, one time maintainer of the CMOS code)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com
Sent: Monday, October 28, 2013 10:08 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] How to store data in non-volatile memory from ACPI?

Aside from the RTC/CMOS storage area that has some very limited amount of storage (64 bytes IIRC), I would think that any OTHER non-volatile memory in the system would be very system specific.

Aside form the above, I’m not aware of any way to allow arbitrary drivers or even ASL Methods to store data in a “standard” non-volatile memory area. How would you manage who accessed this memory and what’s stored there? IOW, what would prevent MY driver from overwriting data that YOUR driver would write to such an area.

Better to store stuff on the disk. You have the same problem with how you exclusively allocate the space, but at least there’s a lot more of it.

Peter
OSR


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

I was once part of a conversation in which I heard a description of how to
make a persistent malware attack by storing persistent information across
system wipes. It would come back after every reinstall. Turns out you
don’t need many bytes to make this happen, from what I recall of the
conversation.

NVRAM that is not CMOS is even better, because removing the CMOS battery
doesn’t clear (or scramble to uselessness) the memory.
joe

> Shatskih, please add some more description on ?On pre-UEFI, BIOS support
> is a must

Your BIOS must be aware of this device, and must provide some special
NVRAM cells to store this information.

BTW - persisting any information (with the exception of some serious
crypto stuff) in the computer across disk wipes is just a moronic idea.
Users and admins DO expect the whole computer to be reset to its original
state after this. Messing with natural user expectations is moronic.

So, garbage in (requirements), garbage out (implementation ideas).

Some devices like TPM crypto really have the serious requirements on
keeping some data inside across disk wipe. But they have some amount of
flash NVRAM inside themselves. This is the best possible way to go.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> NVRAM that is not CMOS is even better, because removing the CMOS battery

doesn’t clear (or scramble to uselessness) the memory.

Battery does not do this too in 100% of times, you need some power-out time to erase the CMOS.

Also, there was an urban myth that, if you do this to fix the mobo issues, you should kiss the battery before re-installing it :slight_smile:

So, jumper is better in both cases :slight_smile: should be present on each and any motherboard.

But once again: if the device really needs to persist some info across disk wipes (and if this is not a figment of imagination of some moronic manager who does not know his clients well) - then having NVRAM on the device itself is the best idea.

IIRC some disk/RAID controllers have this.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

> But once again: if the device really needs to persist some info across disk
wipes (and if this is not a figment of imagination of some moronic manager who
does not know his clients well) - then having NVRAM on the device itself is
the best idea.

The requirement is to store Sensors Calibration data in a Platform. The calibration data are device, Platform and also System Specific. Calibration data are added to System during Assembly by ODM and augmented during its working by some SW (Driver or App). And it is NOT OS specific. As it is done during Factory Assembly, it is not possible for user to recalibrate it accurately at home. And it is a fact that a user will not appreciate loss of Platform calibration on new OS reinstallation.

Current Platforms are deploying Extra Micro Controller to store calibration data. So we are exploring option to remove this Microcontroller and store the data in standard storage locations.

There is a MSFT spec available at http://msdn.microsoft.com/en-us/library/windows/hardware/ jj159304.aspx for reference. I am looking at Non-Microcontroller Sensor Systems (Driver-Based) section, on page 7. “Having NVRAM in the device itself” is existing solution and we are looking at alternatives.

Now do we have any specific suggestion how to implement it?

I thought the point was to use disk INSTEAD of ACPI/UEFI magic. Weren’t
you just looking for a way for the driver to store information that
would survive a reinstall? You’d read and write it from your driver,
not from the BIOS. You wouldn’t survive a reformat, of course, but
that would be an issue with your concept, too.

I am looking to survive the OS reinstallation. Using Registry or file will not survive OS reinstallation, but using UEFI/ACPI will survive. Though this will not survive BIOS change or Disk change. Having access to BIOS NVRAM will survive these also.

In this case, the suggestion given below of putting some flash memory on
the device itself is critical. Consider the following scenario: the
customer buys the board, which has been calibrated at the factory, as part
of a system. Being a customer, they see the board as interchangeable to
any other box that supports its bus, and expect to be able to move the
board around. It is useless to store the calibration data on the
motherboard; if the mothboard fries, and they buy a replacement
motherboard, they’re screwed, because all the calibration data has been
lost.

And, strictly speaking, the sensor calibration data is part of the
/sensor/, not its controller board, and as such, the calibration data
should be uploaded to the sensor, not kept on a controller board.

I would imagine that any sensor that requires calibration is not cheap.
So we have external sensors, a controller board, and a platform that hosts
these. It strikes me that the controller board and the platform are
completely irrelevant here. The sensor calibration becomes part of the
sensor. So if I disconnect sensor A from platform A’ and plug it into
platform B’, its calibration data has to move with it. That says to me
that it belongs in the sensor itself. It most certainly does not belong
on the motherboard, or even the controller board. If you put it on the
controller board, you have to provide a way to upload and download the
individual sensor calibration data so the sensors could be moved
platform-to-platform, or, more critically, that a totally-fried platform
can be swapped in and everything keeps working correctly.

I’d try to explain this to managers using very short and simple words.
“This idea sucks” is the condensed version of that information.
joe

> But once again: if the device really needs to persist some info across
> disk
wipes (and if this is not a figment of imagination of some moronic manager
who
does not know his clients well) - then having NVRAM on the device itself
is
the best idea.

The requirement is to store Sensors Calibration data in a Platform. The
calibration data are device, Platform and also System Specific.
Calibration data are added to System during Assembly by ODM and augmented
during its working by some SW (Driver or App). And it is NOT OS specific.
As it is done during Factory Assembly, it is not possible for user to
recalibrate it accurately at home. And it is a fact that a user will not
appreciate loss of Platform calibration on new OS reinstallation.

Current Platforms are deploying Extra Micro Controller to store
calibration data. So we are exploring option to remove this
Microcontroller and store the data in standard storage locations.

There is a MSFT spec available at
http://msdn.microsoft.com/en-us/library/windows/hardware/ jj159304.aspx
for reference. I am looking at Non-Microcontroller Sensor Systems
(Driver-Based) section, on page 7. “Having NVRAM in the device itself” is
existing solution and we are looking at alternatives.

Now do we have any specific suggestion how to implement it?

>I thought the point was to use disk INSTEAD of ACPI/UEFI magic. Weren’t
you just looking for a way for the driver to store information that
would survive a reinstall? You’d read and write it from your driver,
not from the BIOS. You wouldn’t survive a reformat, of course, but
that would be an issue with your concept, too.

I am looking to survive the OS reinstallation. Using Registry or file will
not survive OS reinstallation, but using UEFI/ACPI will survive. Though
this will not survive BIOS change or Disk change. Having access to BIOS
NVRAM will survive these also.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Back when CMOS was new, I played a bit with it. What was impressive was
how many specs expressed power consumption (under specific conditions) in
femtoampers (1000 femtoamperes = 1 picoampere, 1000 picoamperes = 1
nanoampere, etc.) This means that even a very modest capacitor hook
across the battery could power the memory for some interestingly
significant period of time after the battery is removed. For some
components, the CMOS device came with a minuscle onboard battery whose
life expectancy was 10 years (any scenario requiring serious power
consumption could only arise when the mother board was fully powered, and
therefore the battery was not supplying the power).

For many CMOS designs, the battery life under load did not significantly
differ from the shelf life of the battery. There was an art to this, as
CMOS really can consume a lot of power (relative to its steady-state) when
it is switching at high frequencies. It is also “slow” relative to NMOS
(the basic computer chip technology) and if run at gigahertz frequencies
uses a lot of power (assuming it can be clocked that fast; three decades
ago, you would be lucky to get a few megahertz out of CMOS design, but I
haven’t read a detailed hardware spec in about that same period of
time–there was a time when I could tell you the fanout limits on a wide
variety of chip technologies, but that knowledge is three decades
obsolete).
joe

> NVRAM that is not CMOS is even better, because removing the CMOS battery
> doesn’t clear (or scramble to uselessness) the memory.

Battery does not do this too in 100% of times, you need some power-out
time to erase the CMOS.

Also, there was an urban myth that, if you do this to fix the mobo issues,
you should kiss the battery before re-installing it :slight_smile:

So, jumper is better in both cases :slight_smile: should be present on each and any
motherboard.

But once again: if the device really needs to persist some info across
disk wipes (and if this is not a figment of imagination of some moronic
manager who does not know his clients well) - then having NVRAM on the
device itself
is the best idea.

IIRC some disk/RAID controllers have this.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

>option to remove this Microcontroller and store the data in standard storage locations.

There is no such things. You can also provide the option to safe calibration data to some files and then reload them after the OS reinstall - also a good idea.

You can also provide hidden partition with these files, like the OEM recovery partition on laptops. There is no need in ACPI of UEFI to access it - just hack the partition type to be 7 for MBR or “usual data” for GPT, and you will see the files there.

And, without considering disk storage, you only have tiny undocumented CMOS on pre-UEFI and UEFI env vars (probably of limited size) on UEFI. Neither of this information will survive motherboard battery replacement.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

> I would imagine that any sensor that requires calibration is not cheap.

Not necessary. Consider bad-quality semiconductor temperature sensor, where the crystal geometry tolerances are bad, and the material is not so pure (so that even the energy gap is no more an off book constant).

They will require calibration with the proper temperature source/good temperature sensor.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

> it is switching at high frequencies. It is also “slow” relative to NMOS

(the basic computer chip technology)

Was so 40 years ago.

Computer chips are CMOS since Intel 8080 and for sure 8086.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

So you already have a solution that saves the calibration data right on your
device. This is the optimal design for the problem at hand, and you can
conclude your research into the matter that no better solution is apparent
on account the the many limitations of the other solutions.

You could of course look at reducing the cost of the particular
microcontroller that you use for this purpose. This part should not
significantly contribute to the total cost of your device, but if it does,
then there is very likely a cheaper supplier out there just waiting to get
your business

wrote in message news:xxxxx@ntdev…

But once again: if the device really needs to persist some info across
disk
wipes (and if this is not a figment of imagination of some moronic manager
who
does not know his clients well) - then having NVRAM on the device itself
is
the best idea.

The requirement is to store Sensors Calibration data in a Platform. The
calibration data are device, Platform and also System Specific. Calibration
data are added to System during Assembly by ODM and augmented during its
working by some SW (Driver or App). And it is NOT OS specific. As it is done
during Factory Assembly, it is not possible for user to recalibrate it
accurately at home. And it is a fact that a user will not appreciate loss
of Platform calibration on new OS reinstallation.

Current Platforms are deploying Extra Micro Controller to store calibration
data. So we are exploring option to remove this Microcontroller and store
the data in standard storage locations.

There is a MSFT spec available at
http://msdn.microsoft.com/en-us/library/windows/hardware/ jj159304.aspx for
reference. I am looking at Non-Microcontroller Sensor Systems (Driver-Based)
section, on page 7. “Having NVRAM in the device itself” is existing solution
and we are looking at alternatives.

Now do we have any specific suggestion how to implement it?

I thought the point was to use disk INSTEAD of ACPI/UEFI magic. Weren’t
you just looking for a way for the driver to store information that
would survive a reinstall? You’d read and write it from your driver,
not from the BIOS. You wouldn’t survive a reformat, of course, but
that would be an issue with your concept, too.

I am looking to survive the OS reinstallation. Using Registry or file will
not survive OS reinstallation, but using UEFI/ACPI will survive. Though this
will not survive BIOS change or Disk change. Having access to BIOS NVRAM
will survive these also.

This. Definitely.

The cal data belongs to the device, and thus it belongs ON the device. It doesn’t belong in the system CMOS (even). It doesn’t belong on disk (consider the case of a disk crash). It belongs on the device.

There are NUMEROUS arguments for why this is the best design:

  1. The information is DEVICE specific, not system specific.
  2. Maintainability: Who in their right mind would look for device-specific calibration data in the RTC/CMOS? How would you document this? If you get run over by a beer truck, and your company calls me to fix your driver, I’m sure as hell not going to expect some magic ASL mumbo-jumbo to get the cal data.
  3. Maintainability Part 2: Do you seriously want to have to maintain a BIOS? Get the latest BIOS tools? Only have developers who understand ASL and know how to get the latest Microsoft ASL compiler, and how to use the AMLI debugger maintain this? How many people on the planet do you think have experience developing a BIOS? Who’s going to do periodic maintenance, and update the BIOS when ACPI 6.0 is supported?
  4. Evolution. Do you *really* want to be locked-in to a particular BIOS, on a particular system architecture, for all eternity? What happens when BIOS updates are required?

No, no… you’re looking for answers in the wrong place. Put the cal data where it belongs, on the device. That’s DEFINITELY the right answer, and the least expensive answer in the long run.

Peter
OSR