aboutsummaryrefslogtreecommitdiff
path: root/src/pmm.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2009-08-22 21:31:58 -0400
committerKevin O'Connor <kevin@koconnor.net>2009-08-22 21:31:58 -0400
commit0e9fd6155384da95835fafdb77a487334df825d5 (patch)
tree08803f1be8e502f62178a48b4dd27c3e5a5dbae7 /src/pmm.c
parent51cfbe76701c382a33070c490eedd00d3db8c0ee (diff)
downloadseabios-0e9fd6155384da95835fafdb77a487334df825d5.zip
seabios-0e9fd6155384da95835fafdb77a487334df825d5.tar.gz
seabios-0e9fd6155384da95835fafdb77a487334df825d5.tar.bz2
Add initial support for PMM allocations of permanent memory.
Support PCIv3 PMM requests for permanent memory. Only support permanent high memory requests for now.
Diffstat (limited to 'src/pmm.c')
-rw-r--r--src/pmm.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/pmm.c b/src/pmm.c
index da462fd..3b4aa07 100644
--- a/src/pmm.c
+++ b/src/pmm.c
@@ -30,11 +30,12 @@ struct zone_s {
u32 top, bottom, cur;
};
-struct zone_s ZoneHigh VAR32VISIBLE, ZoneFSeg VAR32VISIBLE;
+struct zone_s ZoneLow VAR32VISIBLE, ZoneHigh VAR32VISIBLE;
+struct zone_s ZoneFSeg VAR32VISIBLE;
struct zone_s ZoneTmpLow VAR32VISIBLE, ZoneTmpHigh VAR32VISIBLE;
struct zone_s *Zones[] VAR32VISIBLE = {
- &ZoneTmpLow, &ZoneFSeg, &ZoneTmpHigh, &ZoneHigh
+ &ZoneTmpLow, &ZoneLow, &ZoneFSeg, &ZoneTmpHigh, &ZoneHigh
};
// Obtain memory from a given zone.
@@ -116,6 +117,9 @@ malloc_setup()
ZoneTmpLow.bottom = BUILD_STACK_ADDR;
ZoneTmpLow.top = ZoneTmpLow.cur = (u32)MAKE_FLATPTR(EBDA_SEGMENT_MINIMUM, 0);
+ // Permanent memory under 1Meg. XXX - not implemented yet.
+ ZoneLow.bottom = ZoneLow.top = ZoneLow.cur = 0xa0000;
+
// Find memory at the top of ram.
struct e820entry *e = find_high_area(CONFIG_MAX_HIGHTABLE+MALLOC_MIN_ALIGN);
if (!e) {
@@ -307,6 +311,12 @@ handle_pmm00(u16 *args)
u16 flags = args[5];
dprintf(3, "pmm00: length=%x handle=%x flags=%x\n"
, length, handle, flags);
+ struct zone_s *lowzone = &ZoneTmpLow, *highzone = &ZoneTmpHigh;
+ if (flags & 8) {
+ // Permanent memory request.
+ lowzone = &ZoneLow;
+ highzone = &ZoneHigh;
+ }
if (!length) {
// Memory size request
switch (flags & 3) {
@@ -314,12 +324,12 @@ handle_pmm00(u16 *args)
case 0:
return 0;
case 1:
- return pmm_getspace(&ZoneTmpLow);
+ return pmm_getspace(lowzone);
case 2:
- return pmm_getspace(&ZoneTmpHigh);
+ return pmm_getspace(highzone);
case 3: {
- u32 spacelow = pmm_getspace(&ZoneTmpLow);
- u32 spacehigh = pmm_getspace(&ZoneTmpHigh);
+ u32 spacelow = pmm_getspace(lowzone);
+ u32 spacehigh = pmm_getspace(highzone);
if (spacelow > spacehigh)
return spacelow;
return spacehigh;
@@ -340,14 +350,14 @@ handle_pmm00(u16 *args)
case 0:
return 0;
case 1:
- return (u32)pmm_malloc(&ZoneTmpLow, handle, size, align);
+ return (u32)pmm_malloc(lowzone, handle, size, align);
case 2:
- return (u32)pmm_malloc(&ZoneTmpHigh, handle, size, align);
+ return (u32)pmm_malloc(highzone, handle, size, align);
case 3: {
- void *data = pmm_malloc(&ZoneTmpLow, handle, size, align);
+ void *data = pmm_malloc(lowzone, handle, size, align);
if (data)
return (u32)data;
- return (u32)pmm_malloc(&ZoneTmpHigh, handle, size, align);
+ return (u32)pmm_malloc(highzone, handle, size, align);
}
}
}