| 1 |
|
| 2 |
|
| 3 |
#include <string.h> |
| 4 |
#include <cbmem.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <mrc_cache.h> |
| 7 |
#include <northbridge/amd/agesa/state_machine.h> |
| 8 |
#include <AGESA.h> |
| 9 |
#include <northbridge/amd/agesa/agesa_helper.h> |
| 10 |
|
| 11 |
|
| 12 |
#define DEFAULT_MRC_VERSION 0 |
| 13 |
|
| 14 |
AGESA_STATUS OemInitResume(AMD_S3_PARAMS *dataBlock) |
| 15 |
{ |
| 16 |
void *nv_storage = NULL; |
| 17 |
size_t nv_storage_size = 0; |
| 18 |
|
| 19 |
nv_storage = mrc_cache_current_mmap_leak(MRC_TRAINING_DATA, DEFAULT_MRC_VERSION, |
| 20 |
&nv_storage_size); |
| 21 |
|
| 22 |
if (nv_storage == NULL || nv_storage_size == 0) { |
| 23 |
printk(BIOS_ERR, "%s: No valid MRC cache!\n", __func__); |
| 24 |
return AGESA_CRITICAL; |
| 25 |
} |
| 26 |
|
| 27 |
dataBlock->NvStorage = nv_storage; |
| 28 |
dataBlock->NvStorageSize = nv_storage_size; |
| 29 |
|
| 30 |
return AGESA_SUCCESS; |
| 31 |
} |
| 32 |
|
| 33 |
AGESA_STATUS OemS3LateRestore(AMD_S3_PARAMS *dataBlock) |
| 34 |
{ |
| 35 |
char *heap = cbmem_find(CBMEM_ID_RESUME_SCRATCH); |
| 36 |
if (heap == NULL) |
| 37 |
return AGESA_FATAL; |
| 38 |
|
| 39 |
printk(BIOS_DEBUG, "Using resume HEAP at %08x\n", |
| 40 |
(unsigned int)(uintptr_t)heap); |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
dataBlock->VolatileStorageSize = HIGH_MEMORY_SCRATCH; |
| 46 |
dataBlock->VolatileStorage = heap; |
| 47 |
return AGESA_SUCCESS; |
| 48 |
} |
| 49 |
|
| 50 |
AGESA_STATUS OemS3Save(AMD_S3_PARAMS *dataBlock) |
| 51 |
{ |
| 52 |
if (mrc_cache_stash_data(MRC_TRAINING_DATA, DEFAULT_MRC_VERSION, |
| 53 |
dataBlock->NvStorage, dataBlock->NvStorageSize) < 0) { |
| 54 |
printk(BIOS_ERR, "%s: Failed to stash MRC data\n", __func__); |
| 55 |
return AGESA_CRITICAL; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
char *heap = cbmem_add(CBMEM_ID_RESUME_SCRATCH, HIGH_MEMORY_SCRATCH); |
| 60 |
if (heap) { |
| 61 |
memset(heap, 0, HIGH_MEMORY_SCRATCH); |
| 62 |
memcpy(heap, dataBlock->VolatileStorage, dataBlock->VolatileStorageSize); |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
backup_mtrr(); |
| 67 |
|
| 68 |
return AGESA_SUCCESS; |
| 69 |
} |