[SeaBIOS] [PATCH v4 2/5] pmm: support looking up a given pattern in FSEG

Michael S. Tsirkin mst at redhat.com
Wed Sep 25 02:34:54 CEST 2013


On Tue, Sep 24, 2013 at 08:15:40PM -0400, Kevin O'Connor wrote:
> On Wed, Sep 25, 2013 at 03:15:40AM +0300, Michael S. Tsirkin wrote:
> > On Tue, Sep 24, 2013 at 07:35:09PM -0400, Kevin O'Connor wrote:
> > > On Mon, Sep 23, 2013 at 09:20:28PM +0300, Michael S. Tsirkin wrote:
> > > > Will be used to find RSDP there.
> > > > 
> > > > Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
> > > 
> > > Just scan from 0xf0000-0x100000.
> > 
> > Is this range guaranteed to be present?
> 
> 0xf0000-0x100000 is the f-segment - it is where the bios lives.  Yes,
> it will be there.
> 
> -Kevin

So will the following do?
I didn't find the function you asked me to look up,
OTOH malloc.c already knows about fseg start and end ...


diff --git a/src/malloc.c b/src/malloc.c
index d150c90..0f5fae7 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -276,17 +276,16 @@ _free(void *data)
+// Find the data block in zone matching a given pattern.
+void *malloc_find_fseg_pattern(void *pattern, unsigned pattern_size)
+{
+    extern u8 zonefseg_start[], zonefseg_end[];
+    unsigned space = zonefseg_end - zonefseg_start;
+    int off;
+
+    if (space < pattern_size)
+        return NULL;
+
+    for (off = 0; off < space - pattern_size; ++off) {
+        if (!memcmp(zonefseg_start + off, pattern, pattern_size))
+            return zonefseg_start + off;
+    }
+    return NULL;
+}



More information about the SeaBIOS mailing list