aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-05-14 15:22:00 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-05-14 15:22:00 -0700
commit4f2568ba84172915df94995df4ad358d2f09cc0e (patch)
treec1a52d8f616b99065d9aac4c9e219c34abcf35e5
parent4c7ad2f6dfc8da45eaafd6898feb319b478dca53 (diff)
downloadsyslinux-4f2568ba84172915df94995df4ad358d2f09cc0e.tar.gz
syslinux-4f2568ba84172915df94995df4ad358d2f09cc0e.tar.xz
syslinux-4f2568ba84172915df94995df4ad358d2f09cc0e.zip
core: fix "sector size" confusionsyslinux-4.00-pre45
Fix the case where the "sector size" used by the pm filesystem driver isn't the same thing as the SECTOR_SIZE/SECTOR_SHIFT macros used in the assembly code. This is a per-device property, and in the particular case of isolinux hybrid, they are not even currently the same (for all others, they are the same for now, but not necessarily in the future.) Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--core/comboot.inc8
-rw-r--r--core/diskfs.inc9
-rw-r--r--core/extern.inc4
-rw-r--r--core/fs/fs.c35
-rw-r--r--core/fs/iso9660/iso9660.c4
-rw-r--r--core/getc.inc5
-rw-r--r--core/isolinux.asm19
-rw-r--r--core/pxelinux.asm11
-rw-r--r--core/runkernel.inc4
9 files changed, 47 insertions, 52 deletions
diff --git a/core/comboot.inc b/core/comboot.inc
index 9255f8a0..b714dd4a 100644
--- a/core/comboot.inc
+++ b/core/comboot.inc
@@ -124,9 +124,8 @@ is_comboot_image:
; Now actually load the file...
pop si ; File handle
mov bx,100h ; Load at <seg>:0100h
- mov cx,10000h >> SECTOR_SHIFT
- ; Absolute maximum # of sectors
- pm_call getfssec
+ mov cx,0FF00h ; Maximum number of bytes
+ pm_call getfsbytes
cmp ecx,65536-256-2 ; Maximum size
ja comboot_too_large
@@ -586,7 +585,8 @@ comapi_derinfo:
%else
; Physical medium...
- mov P_CL,SECTOR_SHIFT
+ mov al,[SectorShift]
+ mov P_CL,al
mov al,[DriveNumber]
mov P_DL,al
mov P_FS,cs
diff --git a/core/diskfs.inc b/core/diskfs.inc
index b8d03762..9f18c765 100644
--- a/core/diskfs.inc
+++ b/core/diskfs.inc
@@ -171,12 +171,3 @@ exten_table_end:
%ifdef debug ; This code for debugging only
debug_magic dw 0D00Dh ; Debug code sentinel
%endif
-
- alignz 4
-BufSafe dw trackbufsize/SECTOR_SIZE ; Clusters we can load into trackbuf
-BufSafeBytes dw trackbufsize ; = how many bytes?
-%ifndef DEPEND
-%if ( trackbufsize % SECTOR_SIZE ) != 0
-%error trackbufsize must be a multiple of SECTOR_SIZE
-%endif
-%endif
diff --git a/core/extern.inc b/core/extern.inc
index 6110db0b..64edea61 100644
--- a/core/extern.inc
+++ b/core/extern.inc
@@ -10,8 +10,10 @@
extern rllpack, rllunpack
; fs.c
- extern fs_init, pm_searchdir, getfssec, pm_mangle_name, load_config
+ extern fs_init, pm_searchdir, getfssec, getfsbytes
+ extern pm_mangle_name, load_config
extern pm_open_file, pm_close_file
+ extern SectorSize, SectorShift
; chdir.c
extern pm_realpath
diff --git a/core/fs/fs.c b/core/fs/fs.c
index 792da02f..3ae12ec9 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -117,6 +117,35 @@ void getfssec(com32sys_t *regs)
regs->ecx.l = bytes_read;
}
+void getfsbytes(com32sys_t *regs)
+{
+ int sectors;
+ bool have_more;
+ uint32_t bytes_read;
+ char *buf;
+ struct file *file;
+ uint16_t handle;
+
+ handle = regs->esi.w[0];
+ file = handle_to_file(handle);
+
+ sectors = regs->ecx.w[0] >> SECTOR_SHIFT(file->fs);
+
+ buf = MK_PTR(regs->es, regs->ebx.w[0]);
+ bytes_read = file->fs->fs_ops->getfssec(file, buf, sectors, &have_more);
+
+ /*
+ * If we reach EOF, the filesystem driver will have already closed
+ * the underlying file... this really should be cleaner.
+ */
+ if (!have_more) {
+ _close_file(file);
+ regs->esi.w[0] = 0;
+ }
+
+ regs->ecx.l = bytes_read;
+}
+
size_t pmapi_read_file(uint16_t *handle, void *buf, size_t sectors)
{
bool have_more;
@@ -353,8 +382,9 @@ void pm_close_file(com32sys_t *regs)
* invoke the fs-specific init function;
* initialize the cache if we need one;
* finally, get the current inode for relative path looking.
- *
*/
+__bss16 uint16_t SectorSize, SectorShift;
+
void fs_init(com32sys_t *regs)
{
static struct fs_info fs; /* The actual filesystem buffer */
@@ -411,4 +441,7 @@ void fs_init(com32sys_t *regs)
fs.root = fs.fs_ops->iget_root(&fs);
fs.cwd = get_inode(fs.root);
}
+
+ SectorShift = fs.sector_shift;
+ SectorSize = fs.sector_size;
}
diff --git a/core/fs/iso9660/iso9660.c b/core/fs/iso9660/iso9660.c
index 4c568bf6..d695e439 100644
--- a/core/fs/iso9660/iso9660.c
+++ b/core/fs/iso9660/iso9660.c
@@ -206,8 +206,8 @@ static struct inode *iso_get_inode(struct fs_info *fs,
inode->blocks = (inode->size + BLOCK_SIZE(fs) - 1) >> BLOCK_SHIFT(fs);
/* We have a single extent for all data */
- inode->next_extent.pstart = de->extent_le << blktosec;
- inode->next_extent.len = inode->blocks << blktosec;
+ inode->next_extent.pstart = (sector_t)de->extent_le << blktosec;
+ inode->next_extent.len = (sector_t)inode->blocks << blktosec;
return inode;
}
diff --git a/core/getc.inc b/core/getc.inc
index efe60de3..33656b40 100644
--- a/core/getc.inc
+++ b/core/getc.inc
@@ -23,7 +23,6 @@ MAX_GETC_LG2 equ 4 ; Max number of file nesting
MAX_GETC equ (1 << MAX_GETC_LG2)
bytes_per_getc_lg2 equ 16-MAX_GETC_LG2
bytes_per_getc equ (1 << bytes_per_getc_lg2)
-secs_per_getc equ bytes_per_getc/SECTOR_SIZE
MAX_UNGET equ 9 ; Max bytes that can be pushed back
struc getc_file
@@ -135,8 +134,8 @@ getc:
and si,si
mov [di+gc_bufbytes],si ; In case SI == 0
jz .empty
- mov cx,bytes_per_getc >> SECTOR_SHIFT
- pm_call getfssec
+ mov cx,bytes_per_getc
+ pm_call getfsbytes
mov [di+gc_bufbytes],cx
mov [di+gc_file],si
jcxz .empty
diff --git a/core/isolinux.asm b/core/isolinux.asm
index d2ba81d9..80607679 100644
--- a/core/isolinux.asm
+++ b/core/isolinux.asm
@@ -1379,22 +1379,3 @@ img_table:
db 80-1 ; Max cylinder
db 36 ; Max sector
db 2-1 ; Max head
-
-;
-; Misc initialized (data) variables
-;
-
-;
-; Variables that are uninitialized in SYSLINUX but initialized here
-;
-; **** ISOLINUX:: We may have to make this flexible, based on what the
-; **** BIOS expects our "sector size" to be.
-;
- alignz 4
-BufSafe dw trackbufsize/SECTOR_SIZE ; Clusters we can load into trackbuf
-BufSafeBytes dw trackbufsize ; = how many bytes?
-%ifndef DEPEND
-%if ( trackbufsize % SECTOR_SIZE ) != 0
-%error trackbufsize must be a multiple of SECTOR_SIZE
-%endif
-%endif
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 204b09c8..0b87e735 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -534,14 +534,3 @@ KeepPXE db 0 ; Should PXE be kept around?
alignz 4
global MyIP
MyIP dd 0 ; My IP address
-;
-; Variables that are uninitialized in SYSLINUX but initialized here
-;
- alignz 4
-BufSafe dw trackbufsize/TFTP_BLOCKSIZE ; Clusters we can load into trackbuf
-BufSafeBytes dw trackbufsize ; = how many bytes?
-%ifndef DEPEND
-%if ( trackbufsize % TFTP_BLOCKSIZE ) != 0
-%error trackbufsize must be a multiple of TFTP_BLOCKSIZE
-%endif
-%endif
diff --git a/core/runkernel.inc b/core/runkernel.inc
index bf67b114..25b073ff 100644
--- a/core/runkernel.inc
+++ b/core/runkernel.inc
@@ -55,10 +55,10 @@ is_linux_kernel:
; work since we might have funny stuff up near the end of memory).
;
call abort_check ; Check for abort key
- mov cx,8000h >> SECTOR_SHIFT ; Half a moby (32K)
+ mov cx,8000h ; Half a moby (32K)
xor bx,bx
pop si ; <A> file pointer
- pm_call getfssec
+ pm_call getfsbytes
cmp cx,1024
jb kernel_corrupt
cmp word [es:bs_bootsign],0AA55h