HomeFreeBSD

Add a validbcd() routine that uses the bcd2bin_data[] array and returns a

Description

Add a validbcd() routine that uses the bcd2bin_data[] array and returns a
bool indicating whether the input value represents a valid BCD byte.

The existing bcd2bin() routine will KASSERT if asked to convert a bad value,
but sometimes the kernel has to handle BCD data from untrusted sources, so
this will provide a mechanism to validate data before attempting conversion.

This would be have easier/cleaner if the bcd2bin_data[] array contained an
out-of-range value (such as 0xff) in the infill locations that aren't valid,
but it's a global symbol that might be referenced by out-of-tree code
relying on the current scheme, so I'm leaving that alone.

Details

Provenance
ianAuthored on
Parents
rS327452: aw_sid: Add support for a64
Branches
Unknown
Tags
Unknown