Commit 0d8efa1
authored
smbios: add enums/bitflags types for some SMBIOS fields (#694)
Currently, most of the SMBIOS fields that we populate are magic numbers,
with comments describing what that magic number indicates. For SMBIOS
enum fields, this isn't too bad, but for bitfields like the various
"characteristics" fields, it's a bit of a shame, since the hex constant
doesn't always make it obvious which bit corresponds to which
characteristic.
To make this a bit nicer, this commit adds enums for most of the SMBIOS
enum fields we currently populate, and bitflags for most of the bitflags
fields. This way, we can refer to them by name rather than as magic
numbers. Also, I've made the `Default` implementation for the various
enum fields return the "unknown" (0x2) variant. Eventually, we may want
to default-initialize more SMBIOS tables --- but, we should probably
hold off on that until *all* the enum fields in the tables we populate
are Rust types with `Default` impls, so that we don't have to manually
initialize some of them to 0x2.
Furthermore, I've added `serde::{Serialize, Deserialize}`
implementations for these SMBIOS field types, in order to support
(eventually) overriding them from the config file. Using structured
types here also lets us perform some nicer validation of said
hypothetical future config file.
Current `dmidecode` output in an Alpine guest on this branch
matches what's on `master`.1 parent 27af670 commit 0d8efa1
3 files changed
Lines changed: 637 additions & 54 deletions
File tree
- bin
- propolis-server/src/lib
- propolis-standalone/src
- lib/propolis/src/firmware/smbios
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
853 | 853 | | |
854 | 854 | | |
855 | 855 | | |
| 856 | + | |
856 | 857 | | |
857 | 858 | | |
858 | 859 | | |
| |||
863 | 864 | | |
864 | 865 | | |
865 | 866 | | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
870 | 871 | | |
871 | 872 | | |
872 | 873 | | |
| |||
882 | 883 | | |
883 | 884 | | |
884 | 885 | | |
885 | | - | |
886 | | - | |
| 886 | + | |
887 | 887 | | |
888 | 888 | | |
889 | 889 | | |
| |||
928 | 928 | | |
929 | 929 | | |
930 | 930 | | |
931 | | - | |
932 | | - | |
| 931 | + | |
933 | 932 | | |
934 | 933 | | |
935 | 934 | | |
936 | 935 | | |
937 | | - | |
938 | | - | |
| 936 | + | |
939 | 937 | | |
940 | 938 | | |
941 | 939 | | |
942 | 940 | | |
943 | 941 | | |
944 | 942 | | |
945 | | - | |
946 | | - | |
| 943 | + | |
| 944 | + | |
947 | 945 | | |
948 | 946 | | |
949 | 947 | | |
950 | 948 | | |
951 | 949 | | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
958 | 953 | | |
959 | 954 | | |
960 | 955 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
812 | 812 | | |
813 | 813 | | |
814 | 814 | | |
| 815 | + | |
| 816 | + | |
815 | 817 | | |
816 | 818 | | |
817 | 819 | | |
818 | 820 | | |
819 | 821 | | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
824 | 826 | | |
825 | 827 | | |
826 | 828 | | |
827 | 829 | | |
828 | 830 | | |
829 | 831 | | |
830 | | - | |
831 | | - | |
| 832 | + | |
832 | 833 | | |
833 | 834 | | |
834 | 835 | | |
| |||
875 | 876 | | |
876 | 877 | | |
877 | 878 | | |
878 | | - | |
879 | | - | |
| 879 | + | |
880 | 880 | | |
881 | 881 | | |
882 | 882 | | |
883 | 883 | | |
884 | | - | |
885 | | - | |
| 884 | + | |
886 | 885 | | |
887 | 886 | | |
888 | 887 | | |
889 | 888 | | |
890 | 889 | | |
891 | 890 | | |
892 | | - | |
893 | | - | |
| 891 | + | |
| 892 | + | |
894 | 893 | | |
895 | 894 | | |
896 | 895 | | |
897 | 896 | | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
904 | 900 | | |
905 | 901 | | |
906 | 902 | | |
| |||
0 commit comments