pupa-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PUPA bugfixes


From: Marco Gerards
Subject: Re: PUPA bugfixes
Date: 11 Nov 2003 22:35:23 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

"Yoshinori K. Okuji" <address@hidden> writes:

> On Friday 07 November 2003 21:24, Marco Gerards wrote:
> > > Also, how much time does it take? 1ms, 100ms, 1s, or more?
> >
> > A few hundred ms.
> 
> Ummh, it's too much. Well, it is better not to use BIOS, as you suggested.
> 
> > It is much easier to manage the cache globally and I see no real
> > disadvantages.
> 
> Ok.


Here is a new patch.  This patch is much simpler than my previous
patch.  It invalidates the complete cache if there was no disk activity
for 5 seconds.

And that other bug fix (LBA related) is still in.

I will check this patch in soon (if there are no objections).

Thanks,
Marco

2003-11-11  Marco Gerards  <address@hidden>

        * disk/i386/pc/biosdisk.c (pupa_biosdisk_open): Correctly check
        for available extensions.

        * include/pupa/i386/pc/time.h: New file.
        * kern/disk.c: Include <pupa/machine/time.h>.
        (PUPA_CACHE_TIMEOUT): New macro.
        (pupa_last_time): New variable.
        (pupa_disk_open): Flush the cache when there was a timeout.
        (pupa_disk_close): Reset the timer.
        * util/misc.c: Include <sys/times.h>
        (pupa_currticks): New function.

diff -upNr pupa.cvs/disk/i386/pc/biosdisk.c pupa/disk/i386/pc/biosdisk.c
--- pupa.cvs/disk/i386/pc/biosdisk.c    2003-01-02 21:12:32.000000000 +0100
+++ pupa/disk/i386/pc/biosdisk.c        2003-11-11 20:35:28.000000000 +0100
@@ -2,6 +2,7 @@
  *  PUPA  --  Preliminary Universal Programming Architecture for GRUB
  *  Copyright (C) 1999,2000,2001,2002  Free Software Foundation, Inc.
  *  Copyright (C) 2002 Yoshinori K. Okuji <address@hidden>
+ *  Copyright (C) 2003 Marco Gerards <address@hidden>
  *
  *  PUPA is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -159,7 +160,7 @@ pupa_biosdisk_open (const char *name, pu
          /* Clear out the DRP.  */
          pupa_memset (drp, 0, sizeof (*drp));
          drp->size = sizeof (*drp);
-         if (pupa_biosdisk_get_diskinfo_int13_extensions (drive, drp))
+         if (!pupa_biosdisk_get_diskinfo_int13_extensions (drive, drp))
            {
              data->flags = PUPA_BIOSDISK_FLAG_LBA;
 
diff -upNr pupa.cvs/include/pupa/err.h pupa/include/pupa/err.h
--- pupa.cvs/include/pupa/err.h 2003-10-29 19:47:31.000000000 +0100
+++ pupa/include/pupa/err.h     2003-11-11 20:16:39.000000000 +0100
@@ -2,7 +2,7 @@
 /*
  *  PUPA  --  Preliminary Universal Programming Architecture for GRUB
  *  Copyright (C) 2002 Yoshinori K. Okuji <address@hidden>
- *  Copyright (C) 2002 Marco Gerards <address@hidden>
+ *  Copyright (C) 2003 Marco Gerards <address@hidden>
  *
  *  PUPA is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
diff -upNr pupa.cvs/include/pupa/i386/pc/time.h pupa/include/pupa/i386/pc/time.h
--- pupa.cvs/include/pupa/i386/pc/time.h        1970-01-01 01:00:00.000000000 
+0100
+++ pupa/include/pupa/i386/pc/time.h    2003-11-11 20:59:11.000000000 +0100
@@ -0,0 +1,33 @@
+/*
+ *  PUPA  --  Preliminary Universal Programming Architecture for GRUB
+ *  Copyright (C) 2003 Marco Gerards <address@hidden>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef KERNEL_TIME_HEADER
+#define KERNEL_TIME_HEADER     1
+
+#ifdef PUPA_UTIL
+# include <time.h>
+# define PUPA_TICKS_PER_SECOND CLOCKS_PER_SEC
+#else
+# define PUPA_TICKS_PER_SECOND 18
+#endif
+
+/* Return the real time in ticks.  */
+pupa_uint32_t pupa_currticks (void);
+
+#endif /* ! KERNEL_TIME_HEADER */
diff -upNr pupa.cvs/kern/disk.c pupa/kern/disk.c
--- pupa.cvs/kern/disk.c        2003-10-29 19:47:35.000000000 +0100
+++ pupa/kern/disk.c    2003-11-11 22:18:23.000000000 +0100
@@ -24,6 +24,13 @@
 #include <pupa/types.h>
 #include <pupa/machine/partition.h>
 #include <pupa/misc.h>
+#include <pupa/machine/time.h>
+
+#define        PUPA_CACHE_TIMEOUT      5
+
+/* The last time the disk was used.  */
+static unsigned long pupa_last_time = 0;
+
 
 /* Disk cache.  */
 struct pupa_disk_cache
@@ -194,6 +201,7 @@ pupa_disk_open (const char *name)
   pupa_disk_t disk;
   pupa_disk_dev_t dev;
   char *raw = (char *) name;
+  unsigned long current_time;
   
   disk = (pupa_disk_t) pupa_malloc (sizeof (*disk));
   if (! disk)
@@ -247,6 +255,15 @@ pupa_disk_open (const char *name)
   if (p)
     disk->partition = pupa_partition_probe (disk, p + 1);
 
+  /* The cache will be invalidated about 5 seconds after a device was
+     closed.  */
+  current_time = pupa_currticks ();
+
+  if (current_time > pupa_last_time + PUPA_CACHE_TIMEOUT * 
PUPA_TICKS_PER_SECOND)
+    pupa_disk_cache_invalidate_all ();
+  
+  pupa_last_time = current_time;
+  
  fail:
   
   if (raw && raw != name)
@@ -267,6 +284,9 @@ pupa_disk_close (pupa_disk_t disk)
   if (disk->dev && disk->dev->close)
     (disk->dev->close) (disk);
 
+  /* Reset the timer.  */
+  pupa_last_time = pupa_currticks ();
+
   pupa_free (disk->partition);
   pupa_free ((void *) disk->name);
   pupa_free (disk);
diff -upNr pupa.cvs/util/misc.c pupa/util/misc.c
--- pupa.cvs/util/misc.c        2003-01-31 04:26:56.000000000 +0100
+++ pupa/util/misc.c    2003-11-11 21:55:12.000000000 +0100
@@ -1,6 +1,7 @@
 /*
  *  PUPA  --  Preliminary Universal Programming Architecture for GRUB
  *  Copyright (C) 2002,2003 Yoshinori K. Okuji <address@hidden>
+ *  Copyright (C) 2003 Marco Gerards <address@hidden>
  *
  *  PUPA is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -23,6 +24,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/times.h>
 
 #include <pupa/util/misc.h>
 #include <pupa/mm.h>
@@ -198,3 +200,11 @@ pupa_putchar (int c)
 {
   putchar (c);
 }
+
+pupa_uint32_t
+pupa_currticks (void)
+{
+  struct tms currtime;
+
+  return times (&currtime);
+}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]