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 warnx("missing required filename to write to"); 38 (void) fprintf(stderr, "Usage: %s <file>\n", argv[0]); 39 exit(EXIT_FAILURE); 40 } 41 42 hwsup = xsu_hwsupport(); 43 f = fopen(argv[1], "w+"); 44 if (f == NULL) { 45 err(EXIT_FAILURE, "failed to open %s", argv[1]); 46 } 47 48 xsu_getfpu(&fpu, hwsup); 49 xsu_dump(f, &fpu, hwsup); 50 51 return (EXIT_SUCCESS); 52 } 53