2004-08-21 Yoshinori K. Okuji <okuji@enbug.org>
Each disk device has its own id now. This is useful to make use of multiple disk devices. * include/grub/disk.h (grub_disk_dev_id): New enum. (GRUB_DISK_DEVICE_BIOSDISK_ID): New constant. (GRUB_DISK_DEVICE_OFDISK_ID): Likewise. * disk/i386/pc/biosdisk.c (grub_biosdisk_dev): Specify GRUB_DISK_DEVICE_BIOSDISK_ID as an id. * disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_dev): Specify GRUB_DISK_DEVICE_OFDISK_ID as an id. * util/i386/pc/biosdisk.c (grub_util_biosdisk_dev): Specify GRUB_DISK_DEVICE_BIOSDISK_ID as an id. * include/grub/disk.h (struct grub_disk_dev): Added a new member "id" which is used by the cache manager. * normal/main.c (grub_normal_init_page): Use "GNU GRUB" instead of just "GRUB".
This commit is contained in:
parent
64372eb442
commit
97543f08fc
7 changed files with 77 additions and 27 deletions
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
||||||
|
2004-08-21 Yoshinori K. Okuji <okuji@enbug.org>
|
||||||
|
|
||||||
|
Each disk device has its own id now. This is useful to make use
|
||||||
|
of multiple disk devices.
|
||||||
|
|
||||||
|
* include/grub/disk.h (grub_disk_dev_id): New enum.
|
||||||
|
(GRUB_DISK_DEVICE_BIOSDISK_ID): New constant.
|
||||||
|
(GRUB_DISK_DEVICE_OFDISK_ID): Likewise.
|
||||||
|
|
||||||
|
* disk/i386/pc/biosdisk.c (grub_biosdisk_dev): Specify
|
||||||
|
GRUB_DISK_DEVICE_BIOSDISK_ID as an id.
|
||||||
|
|
||||||
|
* disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_dev): Specify
|
||||||
|
GRUB_DISK_DEVICE_OFDISK_ID as an id.
|
||||||
|
|
||||||
|
* util/i386/pc/biosdisk.c (grub_util_biosdisk_dev): Specify
|
||||||
|
GRUB_DISK_DEVICE_BIOSDISK_ID as an id.
|
||||||
|
|
||||||
|
* include/grub/disk.h (struct grub_disk_dev): Added a new member
|
||||||
|
"id" which is used by the cache manager.
|
||||||
|
|
||||||
|
* normal/main.c (grub_normal_init_page): Use "GNU GRUB" instead
|
||||||
|
of just "GRUB".
|
||||||
|
|
||||||
2004-08-18 Marco Gerards <metgerards@student.han.nl>
|
2004-08-18 Marco Gerards <metgerards@student.han.nl>
|
||||||
|
|
||||||
* fs/hfs.c: New file.
|
* fs/hfs.c: New file.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* GRUB -- GRand Unified Bootloader
|
* GRUB -- GRand Unified Bootloader
|
||||||
* Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc.
|
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* GRUB is free software; you can redistribute it and/or modify
|
* GRUB is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -319,6 +319,7 @@ grub_biosdisk_write (grub_disk_t disk, unsigned long sector,
|
||||||
static struct grub_disk_dev grub_biosdisk_dev =
|
static struct grub_disk_dev grub_biosdisk_dev =
|
||||||
{
|
{
|
||||||
.name = "biosdisk",
|
.name = "biosdisk",
|
||||||
|
.id = GRUB_DISK_DEVICE_BIOSDISK_ID,
|
||||||
.iterate = grub_biosdisk_iterate,
|
.iterate = grub_biosdisk_iterate,
|
||||||
.open = grub_biosdisk_open,
|
.open = grub_biosdisk_open,
|
||||||
.close = grub_biosdisk_close,
|
.close = grub_biosdisk_close,
|
||||||
|
|
|
@ -146,6 +146,7 @@ grub_ofdisk_write (grub_disk_t disk __attribute ((unused)),
|
||||||
static struct grub_disk_dev grub_ofdisk_dev =
|
static struct grub_disk_dev grub_ofdisk_dev =
|
||||||
{
|
{
|
||||||
.name = "ofdisk",
|
.name = "ofdisk",
|
||||||
|
.id = GRUB_DISK_DEVICE_OFDISK_ID,
|
||||||
.iterate = grub_ofdisk_iterate,
|
.iterate = grub_ofdisk_iterate,
|
||||||
.open = grub_ofdisk_open,
|
.open = grub_ofdisk_open,
|
||||||
.close = grub_ofdisk_close,
|
.close = grub_ofdisk_close,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* GRUB -- GRand Unified Bootloader
|
* GRUB -- GRand Unified Bootloader
|
||||||
* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* GRUB is free software; you can redistribute it and/or modify
|
* GRUB is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -25,6 +25,14 @@
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/device.h>
|
#include <grub/device.h>
|
||||||
|
|
||||||
|
/* These are used to set a device id. When you add a new disk device,
|
||||||
|
you must define a new id for it here. */
|
||||||
|
enum grub_disk_dev_id
|
||||||
|
{
|
||||||
|
GRUB_DISK_DEVICE_BIOSDISK_ID,
|
||||||
|
GRUB_DISK_DEVICE_OFDISK_ID,
|
||||||
|
};
|
||||||
|
|
||||||
struct grub_disk;
|
struct grub_disk;
|
||||||
|
|
||||||
/* Disk device. */
|
/* Disk device. */
|
||||||
|
@ -33,6 +41,9 @@ struct grub_disk_dev
|
||||||
/* The device name. */
|
/* The device name. */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
|
/* The device id used by the cache manager. */
|
||||||
|
unsigned long id;
|
||||||
|
|
||||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||||
int (*iterate) (int (*hook) (const char *name));
|
int (*iterate) (int (*hook) (const char *name));
|
||||||
|
|
||||||
|
|
60
kern/disk.c
60
kern/disk.c
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* GRUB -- GRand Unified Bootloader
|
* GRUB -- GRand Unified Bootloader
|
||||||
* Copyright (C) 2002,2003 Free Software Foundation, Inc.
|
* Copyright (C) 2002,2003,2004 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* GRUB is free software; you can redistribute it and/or modify
|
* GRUB is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -35,7 +35,8 @@ static unsigned long grub_last_time = 0;
|
||||||
/* Disk cache. */
|
/* Disk cache. */
|
||||||
struct grub_disk_cache
|
struct grub_disk_cache
|
||||||
{
|
{
|
||||||
unsigned long id;
|
unsigned long dev_id;
|
||||||
|
unsigned long disk_id;
|
||||||
unsigned long sector;
|
unsigned long sector;
|
||||||
char *data;
|
char *data;
|
||||||
int lock;
|
int lock;
|
||||||
|
@ -56,23 +57,27 @@ grub_disk_cache_get_performance (unsigned long *hits, unsigned long *misses)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
grub_disk_cache_get_index (unsigned long id, unsigned long sector)
|
grub_disk_cache_get_index (unsigned long dev_id, unsigned long disk_id,
|
||||||
|
unsigned long sector)
|
||||||
{
|
{
|
||||||
return ((id * 2606459 + (sector >> GRUB_DISK_CACHE_BITS))
|
return ((dev_id * 524287UL + disk_id * 2606459UL
|
||||||
|
+ (sector >> GRUB_DISK_CACHE_BITS))
|
||||||
% GRUB_DISK_CACHE_NUM);
|
% GRUB_DISK_CACHE_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_disk_cache_invalidate (unsigned long id, unsigned long sector)
|
grub_disk_cache_invalidate (unsigned long dev_id, unsigned long disk_id,
|
||||||
|
unsigned long sector)
|
||||||
{
|
{
|
||||||
unsigned index;
|
unsigned index;
|
||||||
struct grub_disk_cache *cache;
|
struct grub_disk_cache *cache;
|
||||||
|
|
||||||
sector &= ~(GRUB_DISK_CACHE_SIZE - 1);
|
sector &= ~(GRUB_DISK_CACHE_SIZE - 1);
|
||||||
index = grub_disk_cache_get_index (id, sector);
|
index = grub_disk_cache_get_index (dev_id, disk_id, sector);
|
||||||
cache = grub_disk_cache_table + index;
|
cache = grub_disk_cache_table + index;
|
||||||
|
|
||||||
if (cache->id == id && cache->sector == sector && cache->data)
|
if (cache->dev_id == dev_id && cache->disk_id == disk_id
|
||||||
|
&& cache->sector == sector && cache->data)
|
||||||
{
|
{
|
||||||
cache->lock = 1;
|
cache->lock = 1;
|
||||||
grub_free (cache->data);
|
grub_free (cache->data);
|
||||||
|
@ -99,15 +104,17 @@ grub_disk_cache_invalidate_all (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
grub_disk_cache_fetch (unsigned long id, unsigned long sector)
|
grub_disk_cache_fetch (unsigned long dev_id, unsigned long disk_id,
|
||||||
|
unsigned long sector)
|
||||||
{
|
{
|
||||||
struct grub_disk_cache *cache;
|
struct grub_disk_cache *cache;
|
||||||
unsigned index;
|
unsigned index;
|
||||||
|
|
||||||
index = grub_disk_cache_get_index (id, sector);
|
index = grub_disk_cache_get_index (dev_id, disk_id, sector);
|
||||||
cache = grub_disk_cache_table + index;
|
cache = grub_disk_cache_table + index;
|
||||||
|
|
||||||
if (cache->id == id && cache->sector == sector)
|
if (cache->dev_id == dev_id && cache->disk_id == disk_id
|
||||||
|
&& cache->sector == sector)
|
||||||
{
|
{
|
||||||
cache->lock = 1;
|
cache->lock = 1;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -124,28 +131,30 @@ grub_disk_cache_fetch (unsigned long id, unsigned long sector)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_disk_cache_unlock (unsigned long id, unsigned long sector)
|
grub_disk_cache_unlock (unsigned long dev_id, unsigned long disk_id,
|
||||||
|
unsigned long sector)
|
||||||
{
|
{
|
||||||
struct grub_disk_cache *cache;
|
struct grub_disk_cache *cache;
|
||||||
unsigned index;
|
unsigned index;
|
||||||
|
|
||||||
index = grub_disk_cache_get_index (id, sector);
|
index = grub_disk_cache_get_index (dev_id, disk_id, sector);
|
||||||
cache = grub_disk_cache_table + index;
|
cache = grub_disk_cache_table + index;
|
||||||
|
|
||||||
if (cache->id == id && cache->sector == sector)
|
if (cache->dev_id == dev_id && cache->disk_id == disk_id
|
||||||
|
&& cache->sector == sector)
|
||||||
cache->lock = 0;
|
cache->lock = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_disk_cache_store (unsigned long id, unsigned long sector,
|
grub_disk_cache_store (unsigned long dev_id, unsigned long disk_id,
|
||||||
const char *data)
|
unsigned long sector, const char *data)
|
||||||
{
|
{
|
||||||
unsigned index;
|
unsigned index;
|
||||||
struct grub_disk_cache *cache;
|
struct grub_disk_cache *cache;
|
||||||
|
|
||||||
grub_disk_cache_invalidate (id, sector);
|
grub_disk_cache_invalidate (dev_id, disk_id, sector);
|
||||||
|
|
||||||
index = grub_disk_cache_get_index (id, sector);
|
index = grub_disk_cache_get_index (dev_id, disk_id, sector);
|
||||||
cache = grub_disk_cache_table + index;
|
cache = grub_disk_cache_table + index;
|
||||||
|
|
||||||
cache->data = grub_malloc (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
|
cache->data = grub_malloc (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
|
||||||
|
@ -154,7 +163,8 @@ grub_disk_cache_store (unsigned long id, unsigned long sector,
|
||||||
|
|
||||||
grub_memcpy (cache->data, data,
|
grub_memcpy (cache->data, data,
|
||||||
GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
|
GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
|
||||||
cache->id = id;
|
cache->dev_id = dev_id;
|
||||||
|
cache->disk_id = disk_id;
|
||||||
cache->sector = sector;
|
cache->sector = sector;
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
|
@ -259,7 +269,8 @@ grub_disk_open (const char *name)
|
||||||
closed. */
|
closed. */
|
||||||
current_time = grub_get_rtc ();
|
current_time = grub_get_rtc ();
|
||||||
|
|
||||||
if (current_time > grub_last_time + GRUB_CACHE_TIMEOUT * GRUB_TICKS_PER_SECOND)
|
if (current_time > (grub_last_time
|
||||||
|
+ GRUB_CACHE_TIMEOUT * GRUB_TICKS_PER_SECOND))
|
||||||
grub_disk_cache_invalidate_all ();
|
grub_disk_cache_invalidate_all ();
|
||||||
|
|
||||||
grub_last_time = current_time;
|
grub_last_time = current_time;
|
||||||
|
@ -354,12 +365,12 @@ grub_disk_read (grub_disk_t disk, unsigned long sector,
|
||||||
len = size;
|
len = size;
|
||||||
|
|
||||||
/* Fetch the cache. */
|
/* Fetch the cache. */
|
||||||
data = grub_disk_cache_fetch (disk->id, start_sector);
|
data = grub_disk_cache_fetch (disk->dev->id, disk->id, start_sector);
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
/* Just copy it! */
|
/* Just copy it! */
|
||||||
grub_memcpy (buf, data + pos + offset, len);
|
grub_memcpy (buf, data + pos + offset, len);
|
||||||
grub_disk_cache_unlock (disk->id, start_sector);
|
grub_disk_cache_unlock (disk->dev->id, disk->id, start_sector);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -404,7 +415,8 @@ grub_disk_read (grub_disk_t disk, unsigned long sector,
|
||||||
|
|
||||||
/* Copy it and store it in the disk cache. */
|
/* Copy it and store it in the disk cache. */
|
||||||
grub_memcpy (buf, tmp_buf + pos + offset, len);
|
grub_memcpy (buf, tmp_buf + pos + offset, len);
|
||||||
grub_disk_cache_store (disk->id, start_sector, tmp_buf);
|
grub_disk_cache_store (disk->dev->id, disk->id,
|
||||||
|
start_sector, tmp_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call the read hook, if any. */
|
/* Call the read hook, if any. */
|
||||||
|
@ -466,7 +478,7 @@ grub_disk_write (grub_disk_t disk, unsigned long sector,
|
||||||
|
|
||||||
grub_memcpy (tmp_buf + offset, buf, len);
|
grub_memcpy (tmp_buf + offset, buf, len);
|
||||||
|
|
||||||
grub_disk_cache_invalidate (disk->id, sector);
|
grub_disk_cache_invalidate (disk->dev->id, disk->id, sector);
|
||||||
|
|
||||||
if ((disk->dev->write) (disk, sector, 1, tmp_buf) != GRUB_ERR_NONE)
|
if ((disk->dev->write) (disk, sector, 1, tmp_buf) != GRUB_ERR_NONE)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
@ -488,7 +500,7 @@ grub_disk_write (grub_disk_t disk, unsigned long sector,
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
while (n--)
|
while (n--)
|
||||||
grub_disk_cache_invalidate (disk->id, sector++);
|
grub_disk_cache_invalidate (disk->dev->id, disk->id, sector++);
|
||||||
|
|
||||||
buf += len;
|
buf += len;
|
||||||
size -= len;
|
size -= len;
|
||||||
|
|
|
@ -281,7 +281,7 @@ grub_normal_init_page (void)
|
||||||
{
|
{
|
||||||
grub_cls ();
|
grub_cls ();
|
||||||
grub_printf ("\n\
|
grub_printf ("\n\
|
||||||
GRUB version %s\n\n",
|
GNU GRUB version %s\n\n",
|
||||||
PACKAGE_VERSION);
|
PACKAGE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -477,6 +477,7 @@ grub_util_biosdisk_write (grub_disk_t disk, unsigned long sector,
|
||||||
static struct grub_disk_dev grub_util_biosdisk_dev =
|
static struct grub_disk_dev grub_util_biosdisk_dev =
|
||||||
{
|
{
|
||||||
.name = "biosdisk",
|
.name = "biosdisk",
|
||||||
|
.id = GRUB_DISK_DEVICE_BIOSDISK_ID,
|
||||||
.iterate = grub_util_biosdisk_iterate,
|
.iterate = grub_util_biosdisk_iterate,
|
||||||
.open = grub_util_biosdisk_open,
|
.open = grub_util_biosdisk_open,
|
||||||
.close = 0,
|
.close = 0,
|
||||||
|
|
Loading…
Reference in a new issue