Add hibernation image area
[AGL/meta-agl.git] / meta-agl-bsp / meta-renesas / recipes-bsp / u-boot / u-boot / hibernation / 0003-Add-hibernation-image-area.patch
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
5
6 0x40000000 <-> 0x77FFFFFF : kernel
7 0x78000000 <-> 0x7FFFFFFF : hibernation image area
8
9 Signed-off-by: Yuichi Kusakabe <yuichi.kusakabe@jp.fujitsu.com>
10 ---
11  common/cmd_swsuspmem.c | 20 +++++++++++++-------
12  1 file changed, 13 insertions(+), 7 deletions(-)
13
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)
21  #else
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)
27  #endif
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;
31         } while (0)
32  
33  #ifdef PAGEMAP_DEBUG
34 -static int debugout;
35 +static int debugout = 1;
36  static int _last_read_pages;
37  #define PAGEMAP_INFO(_msg, ...)                                \
38         do {                                            \
39 @@ -231,7 +232,7 @@ static inline u32 addr2pg(void *addr)
40  {
41         return ((u32)(addr)) / PAGE_SIZE;
42  }
43 -static void *offt_addr = (void *)0x44000000;
44 +static void *offt_addr = (void *)0x78000000;
45  static int page_read_mem(u64 page, void *addr)
46  {
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[])
49  
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);
56                 return 0;
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)
66  #ifdef PAGEMAP_DEBUG
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[])
69  
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);
76                 return 0;
77 @@ -830,8 +833,11 @@ int do_swsuspmem(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
78                         continue;
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);
87                         remap_idx++;
88  #ifdef PAGEMAP_DEBUG
89 -- 
90 1.8.3.1
91