Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/cpucontrol/amd10h.c
| Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | amd10h_update(const struct ucode_update_params *params) | ||||
| cpuctl_msr_args_t msrargs; | cpuctl_msr_args_t msrargs; | ||||
| cpuctl_update_args_t args; | cpuctl_update_args_t args; | ||||
| const uint8_t *fw_image; | const uint8_t *fw_image; | ||||
| const char *dev, *path; | const char *dev, *path; | ||||
| const void *selected_fw; | const void *selected_fw; | ||||
| size_t fw_size; | size_t fw_size; | ||||
| size_t selected_size; | size_t selected_size; | ||||
| uint32_t revision; | uint32_t revision; | ||||
| uint32_t new_rev; | uint32_t new_rev, old_rev; | ||||
| uint32_t signature; | uint32_t signature; | ||||
| int devfd; | int devfd; | ||||
| int error; | int error; | ||||
| dev = params->dev_path; | dev = params->dev_path; | ||||
| path = params->fw_path; | path = params->fw_path; | ||||
| devfd = params->devfd; | devfd = params->devfd; | ||||
| fw_image = params->fwimage; | fw_image = params->fwimage; | ||||
| Show All 11 Lines | amd10h_update(const struct ucode_update_params *params) | ||||
| signature = idargs.data[0]; | signature = idargs.data[0]; | ||||
| msrargs.msr = MSR_BIOS_SIGN; | msrargs.msr = MSR_BIOS_SIGN; | ||||
| error = ioctl(devfd, CPUCTL_RDMSR, &msrargs); | error = ioctl(devfd, CPUCTL_RDMSR, &msrargs); | ||||
| if (error < 0) { | if (error < 0) { | ||||
| WARN(0, "ioctl(%s)", dev); | WARN(0, "ioctl(%s)", dev); | ||||
| goto done; | goto done; | ||||
| } | } | ||||
| revision = (uint32_t)msrargs.data; | old_rev = revision = (uint32_t)msrargs.data; | ||||
| selected_fw = ucode_amd_find(path, signature, revision, fw_image, | selected_fw = ucode_amd_find(path, signature, &revision, fw_image, | ||||
| fw_size, &selected_size); | fw_size, &selected_size); | ||||
| if (selected_fw != NULL) { | if (selected_fw != NULL) { | ||||
| WARNX(1, "selected ucode size is %zu", selected_size); | WARNX(1, "selected ucode size is %zu", selected_size); | ||||
| fprintf(stderr, "%s: updating cpu %s to revision %#x... ", | fprintf(stderr, | ||||
| path, dev, revision); | "%s: updating cpu %s from rev %#x to rev %#x... ", | ||||
| path, dev, old_rev, revision); | |||||
| args.data = __DECONST(void *, selected_fw); | args.data = __DECONST(void *, selected_fw); | ||||
| args.size = selected_size; | args.size = selected_size; | ||||
| error = ioctl(devfd, CPUCTL_UPDATE, &args); | error = ioctl(devfd, CPUCTL_UPDATE, &args); | ||||
| if (error < 0) { | if (error < 0) { | ||||
| fprintf(stderr, "failed.\n"); | fprintf(stderr, "failed.\n"); | ||||
| warn("ioctl()"); | warn("ioctl()"); | ||||
| goto done; | goto done; | ||||
| Show All 17 Lines | |||||