aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libfsimage/common
diff options
context:
space:
mode:
authorjohn.levon@sun.com <john.levon@sun.com>2007-02-20 14:54:04 -0800
committerjohn.levon@sun.com <john.levon@sun.com>2007-02-20 14:54:04 -0800
commit78b20c695389df112985986f53738f80fdb813d3 (patch)
treee2883eb9672c48f144ef5e70a19aebacc1e74298 /tools/libfsimage/common
parent180211a7532d1a7b2f71dc8a6267bedcef86a3c8 (diff)
downloadxen-78b20c695389df112985986f53738f80fdb813d3.tar.gz
xen-78b20c695389df112985986f53738f80fdb813d3.tar.bz2
xen-78b20c695389df112985986f53738f80fdb813d3.zip
Add iso9660 support to libfsimage.
Signed-off-by: John Levon <john.levon@sun.com>
Diffstat (limited to 'tools/libfsimage/common')
-rw-r--r--tools/libfsimage/common/fsimage_grub.c78
-rw-r--r--tools/libfsimage/common/fsimage_grub.h5
-rw-r--r--tools/libfsimage/common/mapfile-GNU1
-rw-r--r--tools/libfsimage/common/mapfile-SunOS1
4 files changed, 84 insertions, 1 deletions
diff --git a/tools/libfsimage/common/fsimage_grub.c b/tools/libfsimage/common/fsimage_grub.c
index 27a1481eb7..0e12ce5530 100644
--- a/tools/libfsimage/common/fsimage_grub.c
+++ b/tools/libfsimage/common/fsimage_grub.c
@@ -122,6 +122,84 @@ fsig_disk_read_junk(void)
return (&disk_read_junk);
}
+#if defined(__i386__) || defined(__x86_64__)
+
+#ifdef __amd64
+#define BSF "bsfq"
+#else
+#define BSF "bsfl"
+#endif
+unsigned long
+fsig_log2 (unsigned long word)
+{
+ __asm__ (BSF " %1,%0"
+ : "=r" (word)
+ : "r" (word));
+ return word;
+}
+
+#elif defined(__ia64__)
+
+#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# define ia64_popcnt(x) __builtin_popcountl(x)
+#else
+# define ia64_popcnt(x) \
+ ({ \
+ __u64 ia64_intri_res; \
+ asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \
+ ia64_intri_res; \
+ })
+#endif
+
+unsigned long
+fsig_log2 (unsigned long word)
+{
+ unsigned long result;
+
+ result = ia64_popcnt((word - 1) & ~word);
+ return result;
+}
+
+#elif defined(__powerpc__)
+
+#ifdef __powerpc64__
+#define PPC_CNTLZL "cntlzd"
+#else
+#define PPC_CNTLZL "cntlzw"
+#endif
+#define BITS_PER_LONG (sizeof(long) * 8)
+
+static int
+__ilog2(unsigned long x)
+{
+ int lz;
+
+ asm (PPC_CNTLZL " %0,%1" : "=r" (lz) : "r" (x));
+ return BITS_PER_LONG - 1 - lz;
+}
+
+unsigned long
+fsig_log2 (unsigned long word)
+{
+ return __ilog2(word & -word);
+}
+
+#else /* Unoptimized */
+
+unsigned long
+fsig_log2 (unsigned long word)
+{
+ unsigned long result = 0;
+
+ while (!(word & 1UL))
+ {
+ result++;
+ word >>= 1;
+ }
+ return result;
+}
+#endif
+
int
fsig_devread(fsi_file_t *ffi, unsigned int sector, unsigned int offset,
unsigned int bufsize, char *buf)
diff --git a/tools/libfsimage/common/fsimage_grub.h b/tools/libfsimage/common/fsimage_grub.h
index 9fc8c467b2..800a918655 100644
--- a/tools/libfsimage/common/fsimage_grub.h
+++ b/tools/libfsimage/common/fsimage_grub.h
@@ -57,17 +57,20 @@ typedef struct fsig_plugin_ops {
#define disk_read_func (*fsig_disk_read_junk())
#define disk_read_hook (*fsig_disk_read_junk())
#define print_possibilities 0
+#define noisy_printf
#define grub_memset memset
#define grub_memmove memmove
+#define grub_log2 fsig_log2
extern char **fsig_disk_read_junk(void);
+unsigned long fsig_log2(unsigned long);
#define ERR_FSYS_CORRUPT 1
+#define ERR_OUTSIDE_PART 1
#define ERR_SYMLINK_LOOP 1
#define ERR_FILELENGTH 1
#define ERR_BAD_FILETYPE 1
-#define ERR_BAD_FILETYPE 1
#define ERR_FILE_NOT_FOUND 1
fsi_plugin_ops_t *fsig_init(fsi_plugin_t *, fsig_plugin_ops_t *);
diff --git a/tools/libfsimage/common/mapfile-GNU b/tools/libfsimage/common/mapfile-GNU
index 4bffdeafb0..ced9ade69c 100644
--- a/tools/libfsimage/common/mapfile-GNU
+++ b/tools/libfsimage/common/mapfile-GNU
@@ -20,6 +20,7 @@ VERSION {
fsig_init;
fsig_devread;
fsig_substring;
+ fsig_log2;
fsig_fs_buf;
fsig_file_alloc;
fsig_file_buf;
diff --git a/tools/libfsimage/common/mapfile-SunOS b/tools/libfsimage/common/mapfile-SunOS
index 63f17e1832..21ef67605a 100644
--- a/tools/libfsimage/common/mapfile-SunOS
+++ b/tools/libfsimage/common/mapfile-SunOS
@@ -19,6 +19,7 @@ libfsimage.so.1.0 {
fsig_init;
fsig_devread;
fsig_substring;
+ fsig_log2;
fsig_fs_buf;
fsig_file_alloc;
fsig_file_buf;