]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2004-08-21 Yoshinori K. Okuji <okuji@enbug.org>
authorokuji <okuji@localhost>
Sat, 21 Aug 2004 13:54:22 +0000 (13:54 +0000)
committerokuji <okuji@localhost>
Sat, 21 Aug 2004 13:54:22 +0000 (13:54 +0000)
  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".

ChangeLog
disk/i386/pc/biosdisk.c
disk/powerpc/ieee1275/ofdisk.c
include/grub/disk.h
kern/disk.c
normal/main.c
util/i386/pc/biosdisk.c

index 1fef9972e5b74b11ee727a9aebe264a1256754be..b22d59a4d318fa5c2b33a62eaed7da7d3dcd41b8 100644 (file)
--- a/ChangeLog
+++ b/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>
 
        * fs/hfs.c: New file.
index e21d10c877ad91b68d0496df242a79c9ae3d7aa6..723c394dedb1ba2c822547a35af51cf859c92370 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
  *  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 =
   {
     .name = "biosdisk",
+    .id = GRUB_DISK_DEVICE_BIOSDISK_ID,
     .iterate = grub_biosdisk_iterate,
     .open = grub_biosdisk_open,
     .close = grub_biosdisk_close,
index 7c21d6699e4ae4627e44b121972337c5ec746a5f..b70d8931280e358237bce90605f5c577cdeb22bb 100644 (file)
@@ -146,6 +146,7 @@ grub_ofdisk_write (grub_disk_t disk __attribute ((unused)),
 static struct grub_disk_dev grub_ofdisk_dev =
   {
     .name = "ofdisk",
+    .id = GRUB_DISK_DEVICE_OFDISK_ID,
     .iterate = grub_ofdisk_iterate,
     .open = grub_ofdisk_open,
     .close = grub_ofdisk_close,
index 6982735809a476f44af81cf3550aa33db9e3a060..8fda5036a4ddb4b7a07dfcb50def5eb8452a7900 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
  *  it under the terms of the GNU General Public License as published by
 #include <grub/types.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;
 
 /* Disk device.  */
@@ -33,6 +41,9 @@ struct grub_disk_dev
   /* The device 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.  */
   int (*iterate) (int (*hook) (const char *name));
 
index 8ac3a92950a45623d45e0c124c0008115c671348..c913f2d2a00d146bed3fb03e41a8aa0639cf117c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
  *  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.  */
 struct grub_disk_cache
 {
-  unsigned long id;
+  unsigned long dev_id;
+  unsigned long disk_id;
   unsigned long sector;
   char *data;
   int lock;
@@ -56,23 +57,27 @@ grub_disk_cache_get_performance (unsigned long *hits, unsigned long *misses)
 #endif
 
 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);
 }
 
 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;
   struct grub_disk_cache *cache;
 
   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;
 
-  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;
       grub_free (cache->data);
@@ -99,15 +104,17 @@ grub_disk_cache_invalidate_all (void)
 }
 
 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;
   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;
 
-  if (cache->id == id && cache->sector == sector)
+  if (cache->dev_id == dev_id && cache->disk_id == disk_id
+      && cache->sector == sector)
     {
       cache->lock = 1;
 #if 0
@@ -124,28 +131,30 @@ grub_disk_cache_fetch (unsigned long id, unsigned long sector)
 }
 
 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;
   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;
 
-  if (cache->id == id && cache->sector == sector)
+  if (cache->dev_id == dev_id && cache->disk_id == disk_id
+      && cache->sector == sector)
     cache->lock = 0;
 }
 
 static grub_err_t
-grub_disk_cache_store (unsigned long id, unsigned long sector,
-                      const char *data)
+grub_disk_cache_store (unsigned long dev_id, unsigned long disk_id,
+                      unsigned long sector, const char *data)
 {
   unsigned index;
   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->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_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
-  cache->id = id;
+  cache->dev_id = dev_id;
+  cache->disk_id = disk_id;
   cache->sector = sector;
 
   return GRUB_ERR_NONE;
@@ -259,7 +269,8 @@ grub_disk_open (const char *name)
      closed.  */
   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_last_time = current_time;
@@ -354,12 +365,12 @@ grub_disk_read (grub_disk_t disk, unsigned long sector,
        len = size;
 
       /* 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)
        {
          /* Just copy it!  */
          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
        {
@@ -404,7 +415,8 @@ grub_disk_read (grub_disk_t disk, unsigned long sector,
 
          /* Copy it and store it in the disk cache.  */
          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.  */
@@ -466,7 +478,7 @@ grub_disk_write (grub_disk_t disk, unsigned long sector,
          
          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)
            goto finish;
@@ -488,7 +500,7 @@ grub_disk_write (grub_disk_t disk, unsigned long sector,
            goto finish;
 
          while (n--)
-           grub_disk_cache_invalidate (disk->id, sector++);
+           grub_disk_cache_invalidate (disk->dev->id, disk->id, sector++);
 
          buf += len;
          size -= len;
index 4070c5be407bbb6608aa1ee4f7cc9b2144957eae..499e6ffb1402135379228dd7bd832aa477a0f94d 100644 (file)
@@ -281,7 +281,7 @@ grub_normal_init_page (void)
 {
   grub_cls ();
   grub_printf ("\n\
-                             GRUB  version %s\n\n",
+                         GNU GRUB  version %s\n\n",
               PACKAGE_VERSION);
 }
 
index b9071f1cba36d599398d8d837122e84faddefd8e..022574227b449ae44b52c6cbc597603c567d1712 100644 (file)
@@ -477,6 +477,7 @@ grub_util_biosdisk_write (grub_disk_t disk, unsigned long sector,
 static struct grub_disk_dev grub_util_biosdisk_dev =
   {
     .name = "biosdisk",
+    .id = GRUB_DISK_DEVICE_BIOSDISK_ID,
     .iterate = grub_util_biosdisk_iterate,
     .open = grub_util_biosdisk_open,
     .close = 0,