[syslinux:lwip] core, diskio: allocate the disk cache from the heap

syslinux-bot for H. Peter Anvin hpa at zytor.com
Mon Apr 25 16:48:33 PDT 2011


Commit-ID:  6bc5f3b0c7beb4ab445b6d4c7f1f18fcd0cb722e
Gitweb:     http://syslinux.zytor.com/commit/6bc5f3b0c7beb4ab445b6d4c7f1f18fcd0cb722e
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 25 Apr 2011 16:45:50 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 25 Apr 2011 16:45:50 -0700

core, diskio: allocate the disk cache from the heap

Since network buffers are allocated from the heap, and the heap is now
dynamically sized, it makes sense we allocate the disk cache here,
too.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 core/fs/diskio.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/core/fs/diskio.c b/core/fs/diskio.c
index 6683816..4588d4d 100644
--- a/core/fs/diskio.c
+++ b/core/fs/diskio.c
@@ -7,6 +7,7 @@
 #include <fs.h>
 #include <disk.h>
 #include <ilog2.h>
+#include <minmax.h>
 
 #define RETRY_COUNT 6
 
@@ -396,24 +397,21 @@ struct disk *disk_init(uint8_t devno, bool cdrom, sector_t part_start,
     return &disk;
 }
 
-
 /*
  * Initialize the device structure.
- *
- * NOTE: the disk cache needs to be revamped to support multiple devices...
  */
 struct device * device_init(uint8_t devno, bool cdrom, sector_t part_start,
                             uint16_t bsHeads, uint16_t bsSecPerTrack,
 			    uint32_t MaxTransfer)
 {
     static struct device dev;
-    static __hugebss char diskcache[128*1024];
+    extern size_t HighMemSize, MallocStart;
 
     dev.disk = disk_init(devno, cdrom, part_start,
 			 bsHeads, bsSecPerTrack, MaxTransfer);
 
-    dev.cache_data = diskcache;
-    dev.cache_size = sizeof diskcache;
+    dev.cache_size = min(128*1024, (MallocStart-HighMemSize) >> 1);
+    dev.cache_data = malloc(dev.cache_size);
 
     return &dev;
 }



More information about the Syslinux-commits mailing list