Re: 64 bit arithmetic?

2008-06-11 Thread Colin D Bennett
On Wed, 11 Jun 2008 00:54:35 +0800
Bean <[EMAIL PROTECTED]> wrote:

> On Wed, Jun 11, 2008 at 12:26 AM, Colin D Bennett <[EMAIL PROTECTED]>
> wrote:
> > I'm working on implementing a higher resolution timer using the x86
> > TSC.  However, this entails 64-bit arithmetic since on a 2GHz
> > machine it will overflow a 32-bit number every couple of seconds
> > (the TSC counter CPU cycles since boot).
> >
> > So to convert the TSC value into a value in milliseconds, I need to
> > do 64-bit division, but when I try to build GRUB now, I get
> >
> >   undefined reference to `__udivdi3'
> >
> > Is this expected?  Should it be possible for me to do division on
> > grub_uint64_t types?
> >
> > BTW, I'm trying to add it to the kernel image, if this makes a
> > difference.
> 
> Hi.
> 
> You can use grub_divmod64, which is defined in kern/misc.c

Thanks! That works perfectly.


signature.asc
Description: PGP signature
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Drivemap module

2008-06-11 Thread Marco Gerards
Hi Javier,

Javier Martín <[EMAIL PROTECTED]> writes:

> Since the last posts in the "reimplementing the legacy map command"
> thread seemingly died silently, I'm sending the improved version of the
> patch here. If the death of the thread was intentional, please just tell
> me (either nicely or rudely) and I'll be off.

It's not intentional.  This feature is appreciated!  Please do this
scare you away...

The problem is that many developers are really busy at the moment
(unfortunately).  I expect to have more time to review patches in
about 2-3 weeks.

--
Marco



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] biosdisk / open_device() messing up offsets

2008-06-11 Thread Pavel Roskin

Quoting Bean <[EMAIL PROTECTED]>:


I think we should consider having a journaling layer above
grub_disk_read() that would do the substitution and avoid such bugs in
the future.


This should be all right, but we need to move the journal support from
fshelp.c to disk.c, anyone objects ?


No objection from me.  But if it's complicated, we can start with an  
ext2 specific function that would translate offset and size to block  
numbers, apply journal mappings and read the data.


--
Regards,
Pavel Roskin


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] biosdisk / open_device() messing up offsets

2008-06-11 Thread Pavel Roskin

Quoting Bean <[EMAIL PROTECTED]>:


This should be all right, but we need to move the journal support from
fshelp.c to disk.c, anyone objects ?


I've converted ext2.c.  The patch is attached.  The interface should  
be OK for reiserfs.  It looks like the call to grub_fshelp_map_block()  
from grub_ext2_read_inode() was also wrong.  I'm afraid there are some  
wrong places in reiserfs as well.


I would like to commit the patch as soon as possible.  It's a serious  
issue, and we don't want to scare away potential testers and  
contributors.


ChangeLog:
* fs/fshelp.c (grub_fshelp_read): New function.  Implement linear
disk read with journal translation.
* fs/ext2.c: Use grub_fshelp_read() instead of grub_disk_read().
* include/grub/fshelp.h: Declare grub_fshelp_read().

--
Regards,
Pavel Roskin

diff --git a/fs/ext2.c b/fs/ext2.c
index ffe9e33..999bd80 100644
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -257,12 +257,11 @@ inline static grub_err_t
 grub_ext2_blockgroup (struct grub_ext2_data *data, int group, 
  struct grub_ext2_block_group *blkgrp)
 {
-  return grub_disk_read (data->disk,
-(grub_fshelp_map_block (data->journal,
- grub_le_to_cpu32 
(data->sblock.first_data_block) + 1)
- << LOG2_EXT2_BLOCK_SIZE (data)),
-group * sizeof (struct grub_ext2_block_group), 
-sizeof (struct grub_ext2_block_group), (char *) 
blkgrp);
+  return grub_fshelp_read (data->disk, data->journal,
+  grub_le_to_cpu32 (data->sblock.first_data_block) + 1,
+  group * sizeof (struct grub_ext2_block_group),
+  sizeof (struct grub_ext2_block_group),
+  (char *) blkgrp, LOG2_EXT2_BLOCK_SIZE (data));
 }
 
 
@@ -283,11 +282,9 @@ grub_ext2_read_block (grub_fshelp_node_t node, 
grub_disk_addr_t fileblock)
 {
   grub_uint32_t indir[blksz / 4];
 
-  if (grub_disk_read (data->disk, 
- grub_fshelp_map_block(data->journal,
-grub_le_to_cpu32 
(inode->blocks.indir_block))
- << log2_blksz,
- 0, blksz, (char *) indir))
+  if (grub_fshelp_read (data->disk, data->journal,
+   grub_le_to_cpu32 (inode->blocks.indir_block),
+   0, blksz, (char *) indir, log2_blksz))
return grub_errno;
  
   blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]);
@@ -300,18 +297,14 @@ grub_ext2_read_block (grub_fshelp_node_t node, 
grub_disk_addr_t fileblock)
 + blksz / 4);
   grub_uint32_t indir[blksz / 4];
 
-  if (grub_disk_read (data->disk, 
- grub_fshelp_map_block(data->journal,
-grub_le_to_cpu32 
(inode->blocks.double_indir_block))
- << log2_blksz,
- 0, blksz, (char *) indir))
+  if (grub_fshelp_read (data->disk, data->journal,
+   grub_le_to_cpu32 (inode->blocks.double_indir_block),
+   0, blksz, (char *) indir, log2_blksz))
return grub_errno;
 
-  if (grub_disk_read (data->disk,
- grub_fshelp_map_block(data->journal,
-grub_le_to_cpu32 (indir[rblock 
/ perblock]))
- << log2_blksz,
- 0, blksz, (char *) indir))
+  if (grub_fshelp_read (data->disk, data->journal,
+   grub_le_to_cpu32 (indir[rblock / perblock]),
+   0, blksz, (char *) indir, log2_blksz))
return grub_errno;
 
   
@@ -372,12 +365,11 @@ grub_ext2_read_inode (struct grub_ext2_data *data,
 % inodes_per_block;
   
   /* Read the inode.  */
-  if (grub_disk_read (data->disk, 
- grub_fshelp_map_block(data->journal,
-grub_le_to_cpu32 
(blkgrp.inode_table_id) + blkno)
-  << LOG2_EXT2_BLOCK_SIZE (data),
- EXT2_INODE_SIZE (data) * blkoff,
- sizeof (struct grub_ext2_inode), (char *) inode))
+  if (grub_fshelp_read (data->disk, data->journal,
+   grub_le_to_cpu32 (blkgrp.inode_table_id) + blkno,
+   EXT2_INODE_SIZE (data) * blkoff,
+   sizeof (struct grub_ext2_inode), (char *) inode,
+   LOG2_EXT2_BLOCK_SIZE (data)))
 return grub_errno;
   
   return 0;
diff --git a/fs/fshelp.c b/fs/fshelp.c
index faec1f7..52131b0 100644
--- a/fs/fshelp.c
+++ b/fs/fshelp.c
@@ -215,6 +215,45 @@ grub_fshelp_find_file (const char *path, 
grub_fshelp_node_t rootnode,
 }
 
 
+/* Read LEN bytes from the block BLOCK on disk DISK into