~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to grub-core/mmap/mips/yeeloong/uppermem.c

Tags: upstream-1.99~20101122
ImportĀ upstreamĀ versionĀ 1.99~20101122

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Compute amount of lower and upper memory till the first hole. */
 
2
/*
 
3
 *  GRUB  --  GRand Unified Bootloader
 
4
 *  Copyright (C) 2009  Free Software Foundation, Inc.
 
5
 *
 
6
 *  GRUB is free software: you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation, either version 3 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  GRUB is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <grub/memory.h>
 
21
#include <grub/mm.h>
 
22
#include <grub/misc.h>
 
23
#include <grub/machine/memory.h>
 
24
 
 
25
grub_uint64_t
 
26
grub_mmap_get_lower (void)
 
27
{
 
28
  grub_uint64_t lower = 0;
 
29
 
 
30
  auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
 
31
                                  grub_memory_type_t);
 
32
  int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
 
33
                             grub_memory_type_t type)
 
34
    {
 
35
      if (type != GRUB_MEMORY_AVAILABLE)
 
36
        return 0;
 
37
      if (addr == 0)
 
38
        lower = size;
 
39
      return 0;
 
40
    }
 
41
 
 
42
  grub_mmap_iterate (hook);
 
43
  if (lower > GRUB_ARCH_LOWMEMMAXSIZE)
 
44
    lower = GRUB_ARCH_LOWMEMMAXSIZE;
 
45
  return lower;
 
46
}
 
47
 
 
48
grub_uint64_t
 
49
grub_mmap_get_upper (void)
 
50
{
 
51
  grub_uint64_t upper = 0;
 
52
 
 
53
  auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
 
54
                                  grub_memory_type_t);
 
55
  int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
 
56
                             grub_memory_type_t type)
 
57
    {
 
58
      if (type != GRUB_MEMORY_AVAILABLE)
 
59
        return 0;
 
60
      if (addr <= GRUB_ARCH_HIGHMEMPSTART && addr + size
 
61
          > GRUB_ARCH_HIGHMEMPSTART)
 
62
        upper = addr + size - GRUB_ARCH_HIGHMEMPSTART;
 
63
      return 0;
 
64
    }
 
65
 
 
66
  grub_mmap_iterate (hook);
 
67
  return upper;
 
68
}