--- src/pmm.c | 20 +++++--------------- src/util.c | 11 +++++++++++ src/util.h | 1 + 3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/src/pmm.c b/src/pmm.c index 228bc36..682be39 100644 --- a/src/pmm.c +++ b/src/pmm.c @@ -121,7 +121,6 @@ addSpace(struct zone_s *zone, void *start, void *end) tempdetail.datainfo.pprev = pprev; tempdetail.datainfo.data = tempdetail.datainfo.dataend = start; tempdetail.datainfo.allocend = end; - tempdetail.handle = PMM_DEFAULT_HANDLE; struct allocdetail_s *tempdetailp = MAKE_FLATPTR(GET_SEG(SS), &tempdetail); SET_PMMVAR(*pprev, &tempdetailp->datainfo); if (info) @@ -144,11 +143,8 @@ addSpace(struct zone_s *zone, void *start, void *end) }
// Replace temp alloc space with final alloc space - SET_PMMVAR(detail->datainfo.next, tempdetail.datainfo.next); - SET_PMMVAR(detail->datainfo.pprev, tempdetail.datainfo.pprev); - SET_PMMVAR(detail->datainfo.data, tempdetail.datainfo.data); - SET_PMMVAR(detail->datainfo.dataend, tempdetail.datainfo.dataend); - SET_PMMVAR(detail->datainfo.allocend, tempdetail.datainfo.allocend); + memcpy_fl(&detail->datainfo, &tempdetailp->datainfo + , sizeof(detail->datainfo)); SET_PMMVAR(detail->handle, PMM_DEFAULT_HANDLE);
SET_PMMVAR(*tempdetail.datainfo.pprev, &detail->datainfo); @@ -275,15 +271,9 @@ relocate_ebda(u32 newebda, u32 oldebda, u8 ebda_size) // EBDA isn't at end of ram - give up. return -1;
- // Do copy - if (MODESEGMENT) - memcpy_far(FLATPTR_TO_SEG(newebda) - , (void*)FLATPTR_TO_OFFSET(newebda) - , FLATPTR_TO_SEG(oldebda) - , (void*)FLATPTR_TO_OFFSET(oldebda) - , ebda_size * 1024); - else - memmove((void*)newebda, (void*)oldebda, ebda_size * 1024); + // Do copy (this assumes memcpy copies forward - otherwise memmove + // is needed) + memcpy_fl((void*)newebda, (void*)oldebda, ebda_size * 1024);
// Update indexes dprintf(1, "ebda moved from %x to %x\n", oldebda, newebda); diff --git a/src/util.c b/src/util.c index b2a22f7..2c22dfc 100644 --- a/src/util.c +++ b/src/util.c @@ -165,6 +165,17 @@ memcpy_far(u16 d_seg, void *d_far, u16 s_seg, const void *s_far, size_t len) : "cc", "memory"); }
+inline void +memcpy_fl(void *d_fl, const void *s_fl, size_t len) +{ + if (MODESEGMENT) + memcpy_far(FLATPTR_TO_SEG(d_fl), (void*)FLATPTR_TO_OFFSET(d_fl) + , FLATPTR_TO_SEG(s_fl), (void*)FLATPTR_TO_OFFSET(s_fl) + , len); + else + memcpy(d_fl, s_fl, len); +} + void * #undef memcpy memcpy(void *d1, const void *s1, size_t len) diff --git a/src/util.h b/src/util.h index b475c42..7fd76bc 100644 --- a/src/util.h +++ b/src/util.h @@ -186,6 +186,7 @@ inline void memset16_far(u16 d_seg, void *d_far, u16 c, size_t len); void *memset(void *s, int c, size_t n); inline void memcpy_far(u16 d_seg, void *d_far , u16 s_seg, const void *s_far, size_t len); +void memcpy_fl(void *d_fl, const void *s_fl, size_t len); void *memcpy(void *d1, const void *s1, size_t len); #if MODESEGMENT == 0 #define memcpy __builtin_memcpy