1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2023 Oxide Computer Company
  14  */
  15 
  16 /*
  17  * This is a simple program that is meant for use as other programs consuming
  18  * it. It simply reads the extended registers and dumps them. The expectation
  19  * is someone else is showing up and doing something ahead of that.
  20  */
  21 
  22 #include <err.h>
  23 #include <stdio.h>
  24 #include <stdlib.h>
  25 
  26 #include "xsave_util.h"
  27 
  28 static xsu_fpu_t fpu;
  29 
  30 int
  31 main(int argc, char *argv[])
  32 {
  33         FILE *f;
  34         uint32_t hwsup;
  35 
  36         if (argc != 2) {
  37                 errx(EXIT_FAILURE, "missing required filename to write to");
  38         }
  39 
  40         hwsup = xsu_hwsupport();
  41         f = fopen(argv[1], "w+");
  42         if (f == NULL) {
  43                 err(EXIT_FAILURE, "failed to open %s", argv[1]);
  44         }
  45 
  46         xsu_getfpu(&fpu, hwsup);
  47         xsu_dump(f, &fpu, hwsup);
  48 
  49         return (EXIT_SUCCESS);
  50 }