From 6bc5f3b0c7beb4ab445b6d4c7f1f18fcd0cb722e Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 25 Apr 2011 16:45:50 -0700 Subject: 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 --- core/fs/diskio.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'core/fs/diskio.c') diff --git a/core/fs/diskio.c b/core/fs/diskio.c index 66838161..4588d4d2 100644 --- a/core/fs/diskio.c +++ b/core/fs/diskio.c @@ -7,6 +7,7 @@ #include #include #include +#include #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; } -- cgit v1.2.1