1 From eae2ee2090f8c9c140a1b766bd7312be5f0f308d Mon Sep 17 00:00:00 2001
2 From: Yuichi Kusakabe <yuichi.kusakabe@jp.fujitsu.com>
3 Date: Fri, 9 Jun 2017 20:46:54 +0900
4 Subject: [PATCH 3/3] Add hibernation image area
6 0x40000000 <-> 0x77FFFFFF : kernel
7 0x78000000 <-> 0x7FFFFFFF : hibernation image area
9 Signed-off-by: Yuichi Kusakabe <yuichi.kusakabe@jp.fujitsu.com>
11 common/cmd_swsuspmem.c | 20 +++++++++++++-------
12 1 file changed, 13 insertions(+), 7 deletions(-)
14 diff --git a/common/cmd_swsuspmem.c b/common/cmd_swsuspmem.c
15 index 6980aaf..dbc000c 100644
16 --- a/common/cmd_swsuspmem.c
17 +++ b/common/cmd_swsuspmem.c
18 @@ -116,8 +116,9 @@ struct swsusp_finish_context {
19 #define USED_ADDRESS_TOP (CONFIG_SYS_SDRAM_BASE)
20 #define USED_ADDRESS_END (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_LOAD_OFFSET)
22 -#define USED_ADDRESS_TOP (0x40000000)
23 -#define USED_ADDRESS_END (0x48000000)
24 +#define CONFIG_SYS_LOAD_OFFSET 0x0
25 +#define USED_ADDRESS_TOP (CONFIG_SYS_SDRAM_BASE)
26 +#define USED_ADDRESS_END (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_LOAD_OFFSET)
28 #define PG_UB2ZERO(pg) ((pg) - CONFIG_SYS_SDRAM_BASE / PAGE_SIZE)
29 static u32 const exclude_min_page =
30 @@ -157,7 +158,7 @@ static struct swsuspmem_hook *_hook;
35 +static int debugout = 1;
36 static int _last_read_pages;
37 #define PAGEMAP_INFO(_msg, ...) \
39 @@ -231,7 +232,7 @@ static inline u32 addr2pg(void *addr)
41 return ((u32)(addr)) / PAGE_SIZE;
43 -static void *offt_addr = (void *)0x44000000;
44 +static void *offt_addr = (void *)0x78000000;
45 static int page_read_mem(u64 page, void *addr)
47 memcpy(addr, (u8 *)offt_addr + page * PAGE_SIZE, PAGE_SIZE);
48 @@ -577,7 +578,7 @@ int do_checksnapimage(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
50 if (memcmp(HIBERNATE_SIG, swsusp_header->sig, 10)
51 || (swsusp_header->img_size == 0)
52 - || (swsusp_header->img_size > 0x03fff000)) {
53 + || (swsusp_header->img_size > 0x05fff000)) {
54 printf("No hibernation image present\n");
55 CALL_HOOK(err_hook, SWSUSPMEM_BROKENIMAGE);
57 @@ -674,7 +675,9 @@ int do_swsuspmem(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
58 /* Allow for 16 pages of stack */
59 max_page = gd->start_addr_sp / PAGE_SIZE - 32;
60 high_page = (((gd->relocaddr + _bss_end_ofs)
61 - + (PAGE_SIZE - 1)) / PAGE_SIZE) + 1;
62 + + (PAGE_SIZE - 1)) / PAGE_SIZE) + 1 + 0xf;
63 + if (high_page > 0x7ffff)
64 + high_page = 0x7ffff;
65 #define pfn_is_occupied(pfn) (page > max_page && page <= high_page)
67 PAGEMAP_INFO(" *gd->start_addr_sp:%p\n",
68 @@ -711,7 +714,7 @@ int do_swsuspmem(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
70 if (memcmp(HIBERNATE_SIG, swsusp_header->sig, 10)
71 || (swsusp_header->img_size == 0)
72 - || (swsusp_header->img_size > 0x03fff000)) {
73 + || (swsusp_header->img_size > 0x05fff000)) {
74 printf("No hibernation image present\n");
75 CALL_HOOK(err_hook, SWSUSPMEM_BROKENIMAGE);
77 @@ -830,8 +833,11 @@ int do_swsuspmem(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
79 } else if (unlikely(pfn_is_low(page) &&
80 pfn_is_occupied(page))) {
81 + /* Virtual 32-bit original address */
82 remap_orig[remap_idx] = pg2addr(page);
83 + /* allocating new free page */
84 page = free_page_get_next();
85 + /* Virtual 32-bit remap address */
86 remap_temp[remap_idx] = pg2addr(page);