diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-08-10 16:39:29 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-08-10 16:41:10 -0700 |
commit | 710be5ce8bb85a8cfe08acbc242dbee12f6c7871 (patch) | |
tree | 631791084524d5c2ce23168b7891b310820f26f7 | |
parent | f87413e6b7a60e9cfc086232953b7f32a4d1c5f2 (diff) | |
parent | cf68539184ac53fb8a29905e87f5f44f24dbcb37 (diff) | |
download | syslinux-710be5ce8bb85a8cfe08acbc242dbee12f6c7871.tar.gz |
Merge commit 'liu/master'; fix Files[] definition
Resolved Conflicts:
core/extlinux.asm
core/ldlinux.asm
Merge in liu's changes, but fix Files[] to be a private structure
inside the filesystem, thus we don't have to worry about the
size of it in the assembly code at all.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | core/diskfs.inc | 21 | ||||
-rw-r--r-- | core/ext2.c | 75 | ||||
-rw-r--r-- | core/extern.inc | 5 | ||||
-rw-r--r-- | core/extlinux.asm | 2 | ||||
-rw-r--r-- | core/fat.c | 78 | ||||
-rw-r--r-- | core/fs.c | 14 | ||||
-rw-r--r-- | core/include/core.h | 8 | ||||
-rw-r--r-- | core/include/fs.h | 2 | ||||
-rw-r--r-- | core/include/pxe.h | 1 | ||||
-rw-r--r-- | core/iso9660.c | 81 | ||||
-rw-r--r-- | core/isolinux.asm | 15 | ||||
-rw-r--r-- | core/parseconfig.inc | 2 | ||||
-rw-r--r-- | core/pxe.c | 91 | ||||
-rw-r--r-- | core/pxelinux.asm | 30 | ||||
-rw-r--r-- | core/runkernel.inc | 2 | ||||
-rw-r--r-- | core/ui.inc | 4 |
16 files changed, 202 insertions, 229 deletions
diff --git a/core/diskfs.inc b/core/diskfs.inc index 603ada9b..87e1bfe7 100644 --- a/core/diskfs.inc +++ b/core/diskfs.inc @@ -66,11 +66,6 @@ trackbufsize equ 8192 trackbuf resb trackbufsize ; Track buffer goes here ; ends at 2800h - section .bss16 - alignb 16 - global Files -Files resb MAX_OPEN*16 ; 16 == open_file_t_size - ; ; Common bootstrap code for disk-based derivatives ; @@ -115,22 +110,6 @@ Files resb MAX_OPEN*16 ; 16 == open_file_t_size ; %include "ui.inc" - -; -; unmangle_name: Does the opposite of mangle_name; converts a DOS-mangled -; filename to the conventional representation. This is needed -; for the BOOT_IMAGE= parameter for the kernel. -; -; DS:SI -> input mangled file name -; ES:DI -> output buffer -; -; On return, DI points to the first byte after the output name, -; which is set to a null byte. -; -unmangle_name: call strcpy - dec di ; Point to final null byte - ret - ; ; ; kaboom2: once everything is loaded, replace the part of kaboom diff --git a/core/ext2.c b/core/ext2.c index 115ed218..787a6f18 100644 --- a/core/ext2.c +++ b/core/ext2.c @@ -8,7 +8,8 @@ #define FILENAME_MAX_LG2 8 #define FILENAME_MAX (1 << FILENAME_MAX_LG2) -#define MAX_OPEN_LG2 6 +/* The size of open_file_t in extlinux is double of in others */ +#define MAX_OPEN_LG2 (6 - 1) #define MAX_OPEN (1 << MAX_OPEN_LG2) #define MAX_SYMLINKS 64 #define SYMLINK_SECTORS 2 @@ -22,20 +23,20 @@ struct open_file_t { sector_t file_in_sec; /* Sector where inode lives */ uint16_t file_in_off; uint16_t file_mode; + uint32_t pad[3]; /* pad to 2^5 == 0x20 bytes */ }; -extern char Files[]; -struct ext2_inode this_inode; -struct ext2_super_block sb; +static struct open_file_t __bss16 Files[MAX_OPEN]; -uint16_t ClustByteShift, ClustShift; -uint32_t SecPerClust, ClustSize, ClustMask; -uint32_t PtrsPerBlock1, PtrsPerBlock2, PtrsPerBlock3; -int DescPerBlock, InodePerBlock; +static char SymlinkBuf[SYMLINK_SECTORS * SECTOR_SIZE + 64]; -extern char trackbuf[8192]; -char SymlinkBuf[SYMLINK_SECTORS * SECTOR_SIZE + 64]; +static struct ext2_inode this_inode; +static struct ext2_super_block sb; +static uint16_t ClustByteShift, ClustShift; +static uint32_t SecPerClust, ClustSize, ClustMask; +static uint32_t PtrsPerBlock1, PtrsPerBlock2, PtrsPerBlock3; +static int DescPerBlock, InodePerBlock; /** @@ -46,7 +47,7 @@ char SymlinkBuf[SYMLINK_SECTORS * SECTOR_SIZE + 64]; * well, in Syslinux, strcpy() will advance both the dst and src string pointer. * */ -int strecpy(char *dst, char *src, char *end) +static int strecpy(char *dst, char *src, char *end) { while (*src != '\0') *dst++ = *src++; @@ -67,7 +68,7 @@ int strecpy(char *dst, char *src, char *end) * @return: if successful return the file pointer, or return NULL * */ -struct open_file_t *allocate_file() +static struct open_file_t *allocate_file() { struct open_file_t *file = (struct open_file_t *)Files; int i = 0; @@ -90,7 +91,7 @@ struct open_file_t *allocate_file() * @param: file, the file structure we want deallocate * */ -void close_file(struct open_file_t *file) +static void close_file(struct open_file_t *file) { if (file) file->file_bytesleft = 0; @@ -105,7 +106,7 @@ void close_file(struct open_file_t *file) * any whitespace. * */ -void ext2_mangle_name(char *dst, char *src) +static void ext2_mangle_name(char *dst, char *src) { char *p = dst; int i = FILENAME_MAX -1; @@ -137,6 +138,20 @@ void ext2_mangle_name(char *dst, char *src) *dst++ = '\0'; } +/* + * Does the opposite of mangle_name; converts a DOS-mangled + * filename to the conventional representation. This is + * needed for the BOOT_IMAGE= parameter for the kernel. + * + * it returns the lenght of the filename. + */ +static int ext2_unmangle_name(char *dst, char *src) +{ + strcpy(dst, src); + return strlen(src); +} + + /** * get_group_desc: * @@ -147,7 +162,7 @@ void ext2_mangle_name(char *dst, char *src) * @return: the pointer of the group's descriptor * */ -struct ext2_group_desc *get_group_desc(struct fs_info *fs, uint32_t group_num) +static struct ext2_group_desc *get_group_desc(struct fs_info *fs, uint32_t group_num) { block_t block_num; uint32_t offset; @@ -178,7 +193,7 @@ struct ext2_group_desc *get_group_desc(struct fs_info *fs, uint32_t group_num) * @param: offset, same as block * */ -void read_inode(struct fs_info *fs, uint32_t inode_offset, +static void read_inode(struct fs_info *fs, uint32_t inode_offset, struct ext2_inode *dst, struct ext2_group_desc *desc, block_t *block, uint32_t *offset) { @@ -210,7 +225,7 @@ void read_inode(struct fs_info *fs, uint32_t inode_offset, * the first 128 bytes of the inode, stores in ThisInode * */ -struct open_file_t * open_inode(struct fs_info *fs, uint32_t inr, uint32_t *file_len) +static struct open_file_t * open_inode(struct fs_info *fs, uint32_t inr, uint32_t *file_len) { struct open_file_t *file; struct ext2_group_desc *desc; @@ -248,7 +263,7 @@ struct open_file_t * open_inode(struct fs_info *fs, uint32_t inr, uint32_t *file -struct ext4_extent_header * +static struct ext4_extent_header * ext4_find_leaf (struct fs_info *fs, struct ext4_extent_header *eh, block_t block) { struct ext4_extent_idx *index; @@ -282,7 +297,7 @@ ext4_find_leaf (struct fs_info *fs, struct ext4_extent_header *eh, block_t block } /* handle the ext4 extents to get the phsical block number */ -block_t linsector_extent(struct fs_info *fs, block_t block, struct ext2_inode *inode) +static block_t linsector_extent(struct fs_info *fs, block_t block, struct ext2_inode *inode) { struct ext4_extent_header *leaf; struct ext4_extent *ext; @@ -326,7 +341,7 @@ block_t linsector_extent(struct fs_info *fs, block_t block, struct ext2_inode *i * * @return: the physic block number */ -block_t linsector_direct(struct fs_info *fs, uint32_t block, struct ext2_inode *inode) +static block_t linsector_direct(struct fs_info *fs, uint32_t block, struct ext2_inode *inode) { struct cache_struct *cs; @@ -389,7 +404,7 @@ block_t linsector_direct(struct fs_info *fs, uint32_t block, struct ext2_inode * * * @return: physic sector number */ -sector_t linsector(struct fs_info *fs, uint32_t lin_sector) +static sector_t linsector(struct fs_info *fs, uint32_t lin_sector) { uint32_t block = lin_sector >> ClustShift; block_t ret; @@ -430,7 +445,7 @@ static inline int ext2_match_entry (const char * const name, /* * p is at least 6 bytes before the end of page */ -inline struct ext2_dir_entry *ext2_next_entry(struct ext2_dir_entry *p) +static inline struct ext2_dir_entry *ext2_next_entry(struct ext2_dir_entry *p) { return (struct ext2_dir_entry *)((char*)p + p->d_rec_len); } @@ -443,7 +458,7 @@ inline struct ext2_dir_entry *ext2_next_entry(struct ext2_dir_entry *p) * n ext2 block pointer, i.e. anything *except the superblock * */ -void getlinsec_ext(struct fs_info *fs, char *buf, +static void getlinsec_ext(struct fs_info *fs, char *buf, sector_t sector, int sector_cnt) { int ext_cnt = 0; @@ -480,7 +495,7 @@ void getlinsec_ext(struct fs_info *fs, char *buf, * @return: ECX(of regs), number of bytes read * */ -uint32_t ext2_getfssec(struct fs_info *fs, char *buf, +static uint32_t ext2_getfssec(struct fs_info *fs, char *buf, void *open_file, int sectors, int *have_more) { int sector_left, next_sector, sector_idx; @@ -542,7 +557,7 @@ uint32_t ext2_getfssec(struct fs_info *fs, char *buf, * find a dir entry, if find return it or return NULL * */ -struct ext2_dir_entry* find_dir_entry(struct fs_info *fs, struct open_file_t *file,char *filename) +static struct ext2_dir_entry* find_dir_entry(struct fs_info *fs, struct open_file_t *file,char *filename) { int have_more; char *EndBlock = trackbuf + (SecPerClust << SECTOR_SHIFT);; @@ -580,7 +595,7 @@ struct ext2_dir_entry* find_dir_entry(struct fs_info *fs, struct open_file_t *fi } -char* do_symlink(struct fs_info *fs, struct open_file_t *file, +static char* do_symlink(struct fs_info *fs, struct open_file_t *file, uint32_t file_len, char *filename) { int flag, have_more; @@ -633,7 +648,7 @@ char* do_symlink(struct fs_info *fs, struct open_file_t *file, * @out : file lenght in bytes, stores in eax * */ -void ext2_searchdir(char *filename, struct file *file) +static void ext2_searchdir(char *filename, struct file *file) { extern int CurrentDir; @@ -726,7 +741,7 @@ void ext2_searchdir(char *filename, struct file *file) } -void ext2_load_config(com32sys_t *regs) +static void ext2_load_config(com32sys_t *regs) { char *config_name = "extlinux.conf"; com32sys_t out_regs; @@ -751,7 +766,7 @@ void ext2_load_config(com32sys_t *regs) /** * init. the fs meta data, return the block size bits. */ -int ext2_fs_init(struct fs_info *fs) +static int ext2_fs_init(struct fs_info *fs) { struct disk *disk = fs->fs_dev->disk; #if 0 @@ -783,6 +798,6 @@ const struct fs_ops ext2_fs_ops = { .searchdir = ext2_searchdir, .getfssec = ext2_getfssec, .mangle_name = ext2_mangle_name, - .unmangle_name = NULL, + .unmangle_name = ext2_unmangle_name, .load_config = ext2_load_config }; diff --git a/core/extern.inc b/core/extern.inc index 026b8c1b..4c7b149a 100644 --- a/core/extern.inc +++ b/core/extern.inc @@ -14,14 +14,11 @@ ; fs.c extern fs_init, searchdir, getfssec, mangle_name, load_config + extern unmangle_name %if IS_SYSLINUX ; fat.c extern alloc_fill_dir, readdir - -%elif IS_PXELINUX - ; pxe.c - extern gendotquad %endif %endif ; EXTERN_INC diff --git a/core/extlinux.asm b/core/extlinux.asm index 0048cc1b..fd9cfdd2 100644 --- a/core/extlinux.asm +++ b/core/extlinux.asm @@ -23,7 +23,7 @@ ; Some semi-configurable constants... change on your own risk. ; my_id equ extlinux_id -FILENAME_MAX_LG2 equ 8 ; log2(Max filename size Including final null) +FILENAME_MAX_LG2 equ 8 ; log2(Max filename size Including final null) extern ext2_fs_ops ROOT_FS_OPS equ ext2_fs_ops @@ -20,38 +20,37 @@ struct open_file_t { uint32_t file_left; /* number of sectors left */ }; -extern char Files[MAX_OPEN * sizeof(struct open_file_t)]; -extern char trackbuf[8192]; +static struct open_file_t __bss16 Files[MAX_OPEN]; + +extern uint8_t SecPerClust; /* the fat bpb data */ -struct fat_bpb fat; -int FATType = 0; +static struct fat_bpb fat; +static int FATType = 0; /* generic information about FAT fs */ -sector_t FAT; /* Location of (first) FAT */ -sector_t RootDirArea; /* Location of root directory area */ -sector_t RootDir; /* Location of root directory proper */ -sector_t DataArea; /* Location of data area */ -uint32_t TotalSectors; /* Total number of sectors */ -uint32_t ClustSize; /* Bytes/cluster */ -uint32_t ClustMask; /* Sector/cluster - 1 */ -uint8_t CopySuper; /* Distinguish .bs versus .bss */ -uint8_t DriveNumber; /* BIOS drive number */ -uint8_t ClustShift; /* Shift count for sectors/cluster */ -uint8_t ClustByteShift; /* Shift count for bytes/cluster */ - -int CurrentDir; -int PrevDir; +static sector_t FAT; /* Location of (first) FAT */ +static sector_t RootDirArea; /* Location of root directory area */ +static sector_t RootDir; /* Location of root directory proper */ +static sector_t DataArea; /* Location of data area */ +static uint32_t TotalSectors; /* Total number of sectors */ +static uint32_t ClustSize; /* Bytes/cluster */ +static uint32_t ClustMask; /* Sector/cluster - 1 */ +static uint8_t ClustShift; /* Shift count for sectors/cluster */ +static uint8_t ClustByteShift; /* Shift count for bytes/cluster */ + +static int CurrentDir; +static int PrevDir; /* used for long name entry */ -char MangleBuf[12]; -char entry_name[14]; +static char MangleBuf[12]; +static char entry_name[14]; /* try with the biggest long name */ -char long_name[0x40 * 13]; -char *NameStart; -int NameLen; +static char long_name[0x40 * 13]; +static char *NameStart; +static int NameLen; /* do this for readdir, because it called from asm and don't know the fs structure */ static struct fs_info *this_fs = NULL; @@ -65,12 +64,12 @@ static struct fs_info *this_fs = NULL; * @return: if successful return the file pointer, or return NULL * */ -static struct open_file_t *allocate_file() +static struct open_file_t *allocate_file(void) { struct open_file_t *file; int i = 0; - file = (struct open_file_t *)Files; + file = Files; for (; i < MAX_OPEN; i ++ ) { if ( file->file_sector == 0 ) /* found it */ @@ -134,7 +133,7 @@ void close_dir(struct fat_dir_entry *dir) * check for a particular sector in the FAT cache. * */ -struct cache_struct *getfatsector(struct fs_info *fs, sector_t sector) +static struct cache_struct *getfatsector(struct fs_info *fs, sector_t sector) { return get_cache_block(fs->fs_dev, FAT + sector); } @@ -326,7 +325,7 @@ static void __getfssec(struct fs_info *fs, char *buf, struct open_file_t *file, * @return: number of bytes read * */ -uint32_t vfat_getfssec(struct fs_info *fs, char *buf, +static uint32_t vfat_getfssec(struct fs_info *fs, char *buf, void *open_file, int sectors, int *have_more) { uint32_t bytes_read = sectors << SECTOR_SHIFT; @@ -355,7 +354,7 @@ uint32_t vfat_getfssec(struct fs_info *fs, char *buf, * ends on encountering any whitespace. * */ -void vfat_mangle_name(char *dst, char *src) +static void vfat_mangle_name(char *dst, char *src) { char *p = dst; int i = FILENAME_MAX -1; @@ -391,6 +390,19 @@ void vfat_mangle_name(char *dst, char *src) } +/* + * Does the opposite of mangle_name; converts a DOS-mangled + * filename to the conventional representation. This is + * needed for the BOOT_IMAGE= parameter for the kernel. + * + * it returns the lenght of the filename. + */ +static int vfat_unmangle_name(char *dst, char *src) +{ + strcpy(dst, src); + return strlen(src); +} + /** * mangle_dos_name: * @@ -653,7 +665,7 @@ static struct open_file_t* search_dos_dir(struct fs_info *fs, char *MangleBuf, * @return: return the file structure on successful, or NULL. * */ -void vfat_searchdir(char *filename, struct file *file) +static void vfat_searchdir(char *filename, struct file *file) { sector_t dir_sector; uint32_t file_len = 0; @@ -728,7 +740,7 @@ void vfat_searchdir(char *filename, struct file *file) * @param: file * */ -void readdir(com32sys_t *regs)/* +static void readdir(com32sys_t *regs)/* struct fs_info *fs, struct open_file_t* dir_file, char* filename, uint32_t *file_len, uint8_t *attr) */ @@ -852,7 +864,7 @@ void readdir(com32sys_t *regs)/* regs->eax.l = 0; } -void vfat_load_config(com32sys_t *regs) +static void vfat_load_config(com32sys_t *regs) { char syslinux_cfg1[] = "/boot/syslinux/syslinux.cfg"; char syslinux_cfg2[] = "/syslinux/syslinux.cfg"; @@ -901,7 +913,7 @@ static inline void bsr(uint8_t *res, int num) } /* init. the fs meta data, return the block size in bits */ -int vfat_fs_init(struct fs_info *fs) +static int vfat_fs_init(struct fs_info *fs) { int sectors_per_fat; uint32_t clust_num; @@ -942,6 +954,6 @@ const struct fs_ops vfat_fs_ops = { .searchdir = vfat_searchdir, .getfssec = vfat_getfssec, .mangle_name = vfat_mangle_name, - .unmangle_name = NULL, + .unmangle_name = vfat_unmangle_name, .load_config = vfat_load_config }; @@ -23,12 +23,18 @@ void mangle_name(com32sys_t *regs) this_fs->fs_ops->mangle_name(dst, src); } -/**** + void unmangle_name(com32sys_t *regs) { - + char *src = MK_PTR(regs->ds, regs->esi.w[0]); + char *dst = MK_PTR(regs->es, regs->edi.w[0]); + int len; + + len = this_fs->fs_ops->unmangle_name(dst, src); + /* Update the di register to point to the last null char */ + regs->edi.w[0] += len; } -****/ + void getfssec(com32sys_t *regs) { @@ -91,7 +97,7 @@ void fs_init(com32sys_t *regs) /* set up the fs stucture */ fs.fs_name = ops->fs_name; fs.fs_ops = ops; - if (! strcmp(fs.fs_name, "pxe")) + if (!strcmp(fs.fs_name, "pxe")) fs.fs_dev = NULL; else fs.fs_dev = device_init(regs->edx.b[0], regs->edx.b[1], regs->ecx.l, \ diff --git a/core/include/core.h b/core/include/core.h index 069354bb..12ec37ea 100644 --- a/core/include/core.h +++ b/core/include/core.h @@ -6,7 +6,7 @@ extern char core_xfer_buf[65536]; extern char core_cache_buf[65536]; - +extern char trackbuf[]; extern char CurrentDirName[]; extern char ConfigName[]; @@ -27,7 +27,11 @@ int __cdecl core_cfarcall(uint32_t, const void *, uint32_t); void call16(void (*)(void), const com32sys_t *, com32sys_t *); +/* + * __lowmem is in the low 1 MB; __bss16 in the low 64K + */ #define __lowmem __attribute((nocommon,section(".lowmem"))) +#define __bss16 __attribute((nocommon,section(".bss16"))) /* * externs for pxelinux @@ -50,11 +54,9 @@ extern uint8_t MACType; /* MAC address type */ extern uint8_t DHCPMagic; extern uint8_t OverLoad; extern uint32_t RebootTime; - /* TFTP ACK packet */ extern uint16_t ack_packet_buf[]; -extern char trackbuf[]; extern char BootFile[]; extern char PathPrefix[]; extern char LocalDomain[]; diff --git a/core/include/fs.h b/core/include/fs.h index 163808e8..ca4e281a 100644 --- a/core/include/fs.h +++ b/core/include/fs.h @@ -28,7 +28,7 @@ struct fs_ops { void (*searchdir)(char *, struct file *); uint32_t (*getfssec)(struct fs_info *, char *, void * , int, int *); void (*mangle_name)(char *, char *); - void (*unmangle_name)(void); + int (*unmangle_name)(char *, char *); void (*load_config)(com32sys_t *); }; diff --git a/core/include/pxe.h b/core/include/pxe.h index 1aa05068..76fcf14a 100644 --- a/core/include/pxe.h +++ b/core/include/pxe.h @@ -237,7 +237,6 @@ struct open_file_t { uint8_t tftp_unused[3]; /* Currently unused */ uint16_t tftp_pktbuf; /* Packet buffer offset */ } __attribute__ ((packed)); -extern char Files[]; struct pxe_udp_write_pkt { uint16_t status; diff --git a/core/iso9660.c b/core/iso9660.c index 1ce710f7..b1fe64eb 100644 --- a/core/iso9660.c +++ b/core/iso9660.c @@ -23,30 +23,28 @@ struct open_file_t { uint32_t file_bytesleft; uint32_t file_left; }; -extern char Files[]; + +static struct open_file_t __bss16 Files[MAX_OPEN]; struct dir_t { uint32_t dir_lba; /* Directory start (LBA) */ uint32_t dir_len; /* Length in bytes */ uint32_t dir_clust; /* Length in clusters */ }; -struct dir_t RootDir; -struct dir_t CurrentDir; - +static struct dir_t RootDir; +static struct dir_t CurrentDir; -extern char trackbuf[TRACKBUF_SIZE]; -uint16_t BufSafe = TRACKBUF_SIZE >> ISO_SECTOR_SHIFT; -uint16_t BufSafeBytes = TRACKBUF_SIZE; +static uint16_t BufSafe = TRACKBUF_SIZE >> ISO_SECTOR_SHIFT; -char ISOFileName[64]; /* ISO filename canonicalizatin buffer */ -char *ISOFileNameEnd = &ISOFileName[64]; +static char ISOFileName[64]; /* ISO filename canonicalizatin buffer */ +static char *ISOFileNameEnd = &ISOFileName[64]; /* * use to store the block shift, since we treat the hd-mode as 512 bytes * sector size, 2048 bytes block size. we still treat the cdrom as 2048 * bytes sector size and also the block size. */ -int block_shift; +static int block_shift; /** * allocate_file: @@ -54,7 +52,7 @@ int block_shift; * allocate a file structure * */ -struct open_file_t *allocate_file() +static struct open_file_t *allocate_file() { struct open_file_t *file; int i = 0; @@ -76,40 +74,12 @@ struct open_file_t *allocate_file() * Deallocates a file structure * */ -void close_file(struct open_file_t *file) +static void close_file(struct open_file_t *file) { if (file) file->file_sector = 0; } -void getlinsec_cdrom(char *buf, sector_t sector_num, int sectors) -{ - com32sys_t regs; - //static __lowmem char low_buf[65536]; - /* for safe, we use buf + (sectors << SECTOR_SHIFT) here */ - int high_addr = (buf + (sectors << ISO_SECTOR_SHIFT)) > (char *)0x100000; - - memset(®s, 0, sizeof regs); - regs.eax.l = sector_num; - regs.ebp.l = sectors; - - if (high_addr) { - regs.es = SEG(core_xfer_buf); - regs.ebx.w[0] = OFFS(core_xfer_buf); - } else { - regs.es = SEG(buf); - regs.ebx.w[0] = OFFS(buf); - } - - call16(getlinsec, ®s, NULL); - - if (high_addr) - memcpy(buf, core_xfer_buf, sectors << ISO_SECTOR_SHIFT); -} - - - - /** * mangle_name: * @@ -124,7 +94,7 @@ void getlinsec_cdrom(char *buf, sector_t sector_num, int sectors) * a bit of an easier job. * */ -void iso_mangle_name(char *dst, char *src) +static void iso_mangle_name(char *dst, char *src) { char *p = dst; int i = FILENAME_MAX - 1; @@ -159,6 +129,19 @@ void iso_mangle_name(char *dst, char *src) } +/* + * Does the opposite of mangle_name; converts a DOS-mangled + * filename to the conventional representation. This is + * needed for the BOOT_IMAGE= parameter for the kernel. + * + * it returns the lenght of the filename. + */ +static int iso_unmangle_name(char *dst, char *src) +{ + strcpy(dst, src); + return strlen(src); +} + /** * compare the names si and di and report if they are * equal from an ISO 9600 perspective. @@ -171,7 +154,7 @@ void iso_mangle_name(char *dst, char *src) * @return: 1 on match, or 0. * */ -int iso_compare_names(char *de_name, int *len, char *file_name) +static int iso_compare_names(char *de_name, int *len, char *file_name) { char *p = ISOFileName; char c1, c2; @@ -244,7 +227,7 @@ static inline int cdrom_read_sectors(struct disk *disk, void *buf, int block, in * @param: have_more, to indicate if we have reach the end of the file * */ -uint32_t iso_getfssec(struct fs_info *fs, char *buf, +static uint32_t iso_getfssec(struct fs_info *fs, char *buf, void *open_file, int sectors, int *have_more) { uint32_t bytes_read = sectors << ISO_SECTOR_SHIFT; @@ -282,7 +265,7 @@ uint32_t iso_getfssec(struct fs_info *fs, char *buf, * res will return the result. * */ -int do_search_dir(struct fs_info *fs, struct dir_t *dir, +static int do_search_dir(struct fs_info *fs, struct dir_t *dir, char *name, uint32_t *file_len, void **res) { struct open_file_t *file; @@ -423,11 +406,11 @@ int do_search_dir(struct fs_info *fs, struct dir_t *dir, * can read a diretory.(Just thought of mine, liu) * */ -void iso_searchdir(char *filename, struct file *file) +static void iso_searchdir(char *filename, struct file *file) { struct open_file_t *open_file = NULL; struct dir_t *dir; - uint32_t file_len; + uint32_t file_len = 0; int ret; void *res; @@ -488,7 +471,7 @@ void iso_searchdir(char *filename, struct file *file) #endif } -void iso_load_config(com32sys_t *regs) +static void iso_load_config(com32sys_t *regs) { char *config_name = "isolinux.cfg"; com32sys_t out_regs; @@ -501,7 +484,7 @@ void iso_load_config(com32sys_t *regs) } -int iso_fs_init(struct fs_info *fs) +static int iso_fs_init(struct fs_info *fs) { char *iso_dir; char *boot_dir = "/boot/isolinux"; @@ -570,6 +553,6 @@ const struct fs_ops iso_fs_ops = { .searchdir = iso_searchdir, .getfssec = iso_getfssec, .mangle_name = iso_mangle_name, - .unmangle_name = NULL, + .unmangle_name = iso_unmangle_name, .load_config = iso_load_config }; diff --git a/core/isolinux.asm b/core/isolinux.asm index 41777d79..21e74740 100644 --- a/core/isolinux.asm +++ b/core/isolinux.asm @@ -1329,21 +1329,6 @@ is_disk_image: .done_sector: ret -; -; unmangle_name: Does the opposite of mangle_name; converts a DOS-mangled -; filename to the conventional representation. This is needed -; for the BOOT_IMAGE= parameter for the kernel. -; -; DS:SI -> input mangled file name -; ES:DI -> output buffer -; -; On return, DI points to the first byte after the output name, -; which is set to a null byte. -; -unmangle_name: call strcpy - dec di ; Point to final null byte - ret - ; ----------------------------------------------------------------------------- ; Common modules diff --git a/core/parseconfig.inc b/core/parseconfig.inc index 37091c99..af7d514f 100644 --- a/core/parseconfig.inc +++ b/core/parseconfig.inc @@ -409,7 +409,7 @@ commit_vk: mov cx,7 ; "initrd=" rep movsb mov si,InitRD - call unmangle_name + pm_call unmangle_name mov al,' ' stosb @@ -15,34 +15,34 @@ #define GPXE 1 #define USE_PXE_PROVIDED_STACK 0 -char *err_nopxe = "No !PXE or PXENV+ API found; we're dead...\n"; -char *err_pxefailed = "PXE API call failed, error "; -char *err_udpinit = "Failed to initialize UDP stack\n"; -char *err_noconfig = "Unable to locate configuration file\n"; -char *err_damage = "TFTP server sent an incomprehesible reply\n"; +static struct open_file_t __bss16 Files[MAX_OPEN]; -char *tftpprefix_msg = "TFTP prefix: "; -char *get_packet_msg = "Getting cached packet "; +static char *err_nopxe = "No !PXE or PXENV+ API found; we're dead...\n"; +static char *err_pxefailed = "PXE API call failed, error "; +static char *err_udpinit = "Failed to initialize UDP stack\n"; -uint16_t NextSocket = 49152; +static char *tftpprefix_msg = "TFTP prefix: "; +static char *get_packet_msg = "Getting cached packet "; + +static uint16_t NextSocket = 49152; static int has_gpxe; +static uint8_t uuid_dashes[] = {4, 2, 2, 2, 6, 0}; int HaveUUID = 0; -uint8_t uuid_dashes[] = {4, 2, 2, 2, 6, 0}; static const uint8_t TimeoutTable[] = { 2, 2, 3, 3, 4, 5, 6, 7, 9, 10, 12, 15, 18, 21, 26, 31, 37, 44, 53, 64, 77, 92, 110, 132, 159, 191, 229, 255, 255, 255, 255, 0 }; -char *mode = "octet"; -char *tsize_str = "tsize"; -int tsize_len = 6; /* We should include the final null here */ +static char *mode = "octet"; +static char *tsize_str = "tsize"; +static int tsize_len = 6; /* We should include the final null here */ -char *blksize_str = "blksize"; -int blksize_len = 8; +static char *blksize_str = "blksize"; +static int blksize_len = 8; -char *asciidec = "1408"; +static char *asciidec = "1408"; @@ -497,6 +497,28 @@ static void pxe_mangle_name(char *dst, char *src) #endif } + +/* + * Does the opposite of mangle_name; converts a DOS-mangled + * filename to the conventional representation. This is + * needed for the BOOT_IMAGE= parameter for the kernel. + * + * it returns the lenght of the filename. + */ +static int pxe_unmangle_name(char *dst, char *src) +{ + uint32_t ip = *(uint32_t *)src; + int ip_len = 0; + + if (ip != 0 && ip != -1) { + ip_len = gendotquad(dst, *(uint32_t *)src); + dst += ip_len; + } + src += 4;; + strcpy(dst, src); + + return strlen(src) + ip_len; +} /* * @@ -913,8 +935,10 @@ static void pxe_searchdir(char *filename, struct file *file) * Now we need to parse the OACK packet to get the transfer * and packet sizes. */ - if (!buffersize) + if (!buffersize) { + filesize = -1; goto done; /* No options acked */ + } /* * If we find an option which starts with a NUL byte, @@ -927,21 +951,21 @@ static void pxe_searchdir(char *filename, struct file *file) options = packet_buf + 2; if (*options == 0) goto done; - - dst = src = options; - while (buffersize--) { - if (*src == 0) - break; /* found a final null */ - *dst++ = *src++ | 0x20; - if (!buffersize) - goto done; /* found no final null */ - } - - /* - * Parse option pointed to by options; guaranteed to be null-terminated - */ p = options; + do { + dst = src = p; + while (buffersize--) { + if (*src == 0) + break; /* found a final null */ + *dst++ = *src++ | 0x20; + if (!buffersize) + goto done; /* found no final null */ + } + + /* + * Parse option pointed to by options; guaranteed to be null-terminated + */ tftp_opt = tftp_options; for (i = 0; i < tftp_opts; i++) { if (!strncmp(p, tftp_opt->str_ptr,tftp_opt->str_len)) @@ -954,7 +978,7 @@ static void pxe_searchdir(char *filename, struct file *file) p += tftp_opt->str_len; /* get the address of the filed that we want to write on */ - data_ptr = (uint32_t *)((char *)file + tftp_opt->offset); + data_ptr = (uint32_t *)((char *)open_file + tftp_opt->offset); *data_ptr = 0; /* do convert a number-string to decimal number, just like atoi */ @@ -965,7 +989,7 @@ static void pxe_searchdir(char *filename, struct file *file) goto err_reply; /* Not a decimal digit */ *data_ptr = *data_ptr * 10 + *p++ - '0'; } - + p++; }while (buffersize); } else { @@ -1137,7 +1161,8 @@ static void pxe_load_config(com32sys_t *regs) if (try_load(regs)) return; - /* call16(no_config, NULL, NULL); */ + printf("Unable to locate configuration file\n"); + call16(kaboom, NULL, NULL); } @@ -1538,6 +1563,6 @@ const struct fs_ops pxe_fs_ops = { .searchdir = pxe_searchdir, .getfssec = pxe_getfssec, .mangle_name = pxe_mangle_name, - .unmangle_name = NULL, + .unmangle_name = pxe_unmangle_name, .load_config = pxe_load_config }; diff --git a/core/pxelinux.asm b/core/pxelinux.asm index 1da65be5..cfaf5db6 100644 --- a/core/pxelinux.asm +++ b/core/pxelinux.asm @@ -434,36 +434,6 @@ kaboom: ; -; unmangle_name: Does the opposite of mangle_name; converts a DOS-mangled -; filename to the conventional representation. This is needed -; for the BOOT_IMAGE= parameter for the kernel. -; -; NOTE: The output buffer needs to be able to hold an -; expanded IP address. -; -; DS:SI -> input mangled file name -; ES:DI -> output buffer -; -; On return, DI points to the first byte after the output name, -; which is set to a null byte. -; -unmangle_name: - push eax - lodsd - and eax,eax - jz .noip - cmp eax,-1 - jz .noip ; URL - pm_call gendotquad - mov ax,'::' - stosw -.noip: - call strcpy - dec di ; Point to final null byte - pop eax - ret - -; ; pxenv ; ; This is the main PXENV+/!PXE entry point, using the PXENV+ diff --git a/core/runkernel.inc b/core/runkernel.inc index f44e8b35..68ab9fac 100644 --- a/core/runkernel.inc +++ b/core/runkernel.inc @@ -585,7 +585,7 @@ loadinitrd: push edi mov si,InitRD mov di,InitRDCName - call unmangle_name ; Create human-readable name + pm_call unmangle_name ; Create human-readable name sub di,InitRDCName mov [InitRDCNameLen],di mov di,InitRD diff --git a/core/ui.inc b/core/ui.inc index 508a6f28..87d0c647 100644 --- a/core/ui.inc +++ b/core/ui.inc @@ -472,7 +472,7 @@ bad_kernel: mov si,KernelName mov di,KernelCName push di - call unmangle_name ; Get human form + pm_call unmangle_name ; Get human form mov si,err_notfound ; Complain about missing kernel call writestr pop si ; KernelCName @@ -601,7 +601,7 @@ kernel_good: mov si,KernelName mov di,KernelCName - call unmangle_name + pm_call unmangle_name sub di,KernelCName mov [KernelCNameLen],di |