/* FLASH status codes */ #define FLASH_NO_OP -1099 /* No operation initiated by user */ #define FLASH_NO_AUTH -9002 /* Not a service authority partition */
/* Validate image status values */ #define VALIDATE_IMG_READY -1001 /* Image ready for validation */ #define VALIDATE_IMG_INCOMPLETE -1002 /* User copied < VALIDATE_BUF_SIZE */
/* Manage image status values */ #define MANAGE_ACTIVE_ERR -9001 /* Cannot overwrite active img */
/* Flash image status values */ #define FLASH_IMG_READY 0 /* Img ready for flash on reboot */ #define FLASH_INVALID_IMG -1003 /* Flash image shorter than expected */ #define FLASH_IMG_NULL_DATA -1004 /* Bad data in sg list entry */ #define FLASH_IMG_BAD_LEN -1005 /* Bad length in sg list entry */
/* Validate image update result tokens */ #define VALIDATE_TMP_UPDATE 0 /* T side will be updated */ #define VALIDATE_FLASH_AUTH 1 /* Partition does not have authority */ #define VALIDATE_INVALID_IMG 2 /* Candidate image is not valid */ #define VALIDATE_CUR_UNKNOWN 3 /* Current fixpack level is unknown */ /* * Current T side will be committed to P side before being replace with new * image, and the new image is downlevel from current image
*/ #define VALIDATE_TMP_COMMIT_DL 4 /* * Current T side will be committed to P side before being replaced with new * image
*/ #define VALIDATE_TMP_COMMIT 5 /* * T side will be updated with a downlevel image
*/ #define VALIDATE_TMP_UPDATE_DL 6 /* * The candidate image's release date is later than the system's firmware * service entitlement date - service warranty period has expired
*/ #define VALIDATE_OUT_OF_WRNTY 7
/* * Validate output format: * validate result token * current image version details * new image version details
*/ static ssize_t validate_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{ struct validate_flash_t *args_buf = &validate_flash_data; int len;
/* Candidate image is not validated */ if (args_buf->status < VALIDATE_TMP_UPDATE) {
len = sprintf(buf, "%d\n", args_buf->status); goto out;
}
/* Result token */
len = sprintf(buf, "%d\n", args_buf->result);
/* Current and candidate image version details */ if ((args_buf->result != VALIDATE_TMP_UPDATE) &&
(args_buf->result < VALIDATE_CUR_UNKNOWN)) goto out;
if (args_buf->buf_size > (VALIDATE_BUF_SIZE - len)) {
memcpy(buf + len, args_buf->buf, VALIDATE_BUF_SIZE - len);
len = VALIDATE_BUF_SIZE;
} else {
memcpy(buf + len, args_buf->buf, args_buf->buf_size);
len += args_buf->buf_size;
}
out: /* Set status to default */
args_buf->status = FLASH_NO_OP; return len;
}
/* * Validate candidate firmware image * * Note: * We are only interested in first 4K bytes of the * candidate image.
*/ static ssize_t validate_store(struct kobject *kobj, struct kobj_attribute *attr, constchar *buf, size_t count)
{ struct validate_flash_t *args_buf = &validate_flash_data;
list = opal_vmalloc_to_sg_list(image_data.data, image_data.size); if (!list) goto invalid_img;
/* First entry address */
addr = __pa(list);
flash:
rc = opal_update_flash(addr);
invalid_img: return rc;
}
/* This gets called just before system reboots */ void opal_flash_update_print_message(void)
{ if (update_flash_data.status != FLASH_IMG_READY) return;
pr_alert("FLASH: Flashing new firmware\n");
pr_alert("FLASH: Image is %u bytes\n", image_data.size);
pr_alert("FLASH: Performing flash and reboot/shutdown\n");
pr_alert("FLASH: This will take several minutes. Do not power off!\n");
/* Small delay to help getting the above message out */
msleep(500);
}
if (image_data.size > MAX_IMAGE_SIZE) {
pr_warn("FLASH: Too large image\n"); return -EINVAL;
} if (image_data.size < VALIDATE_BUF_SIZE) {
pr_warn("FLASH: Image is shorter than expected\n"); return -EINVAL;
}
image_data.data = vzalloc(PAGE_ALIGN(image_data.size)); if (!image_data.data) {
pr_err("%s : Failed to allocate memory\n", __func__); return -ENOMEM;
}
staticstruct attribute *image_op_attrs[] = {
&validate_attribute.attr,
&manage_attribute.attr,
&update_attribute.attr,
NULL /* need to NULL terminate the list of attributes */
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.