summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fs/ext2/ext2.c77
-rw-r--r--core/fs/fat/fat.c230
-rw-r--r--core/fs/iso9660/iso9660.c47
-rw-r--r--core/fs/pxe/pxe.c197
-rw-r--r--core/isolinux.asm33
-rw-r--r--core/pxelinux.asm170
6 files changed, 210 insertions, 544 deletions
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index 34aba24f..dcd4a49b 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -1,13 +1,14 @@
#include <stdio.h>
#include <string.h>
-#include "cache.h"
-#include "core.h"
-#include "disk.h"
+#include <cache.h>
+#include <core.h>
+#include <disk.h>
+#include <fs.h>
#include "ext2_fs.h"
-#include "fs.h"
#define MAX_SYMLINKS 64
#define SYMLINK_SECTORS 2
+static char SymlinkBuf[SYMLINK_SECTORS * SECTOR_SIZE + 64];
/*
* File structure, This holds the information for each currently open file
@@ -20,11 +21,8 @@ struct open_file_t {
uint16_t file_mode;
uint32_t pad[3]; /* pad to 2^5 == 0x20 bytes */
};
-
static struct open_file_t Files[MAX_OPEN];
-static char SymlinkBuf[SYMLINK_SECTORS * SECTOR_SIZE + 64];
-
static struct ext2_inode this_inode;
static struct ext2_super_block sb;
@@ -33,13 +31,8 @@ static uint32_t SecPerClust, ClustSize, ClustMask;
static uint32_t PtrsPerBlock1, PtrsPerBlock2, PtrsPerBlock3;
static int DescPerBlock, InodePerBlock;
-
-/**
- * strecpy:
- *
+/*
* just like the function strcpy(), except it returns non-zero if overflow.
- *
- * well, in Syslinux, strcpy() will advance both the dst and src string pointer.
*
*/
static int strecpy(char *dst, char *src, char *end)
@@ -55,12 +48,8 @@ static int strecpy(char *dst, char *src, char *end)
}
-/**
- * allocate_file:
- *
- * Allocate a file structure
- *
- * @return: if successful return the file pointer, or return NULL
+/*
+ * Allocate a file structure, if successful return the file pointer, or NULL.
*
*/
static struct open_file_t *allocate_file(void)
@@ -97,8 +86,6 @@ static void ext2_close_file(struct file *file)
}
/**
- * get_group_desc:
- *
* get the group's descriptor of group_num
*
* @param: group_num, the group number;
@@ -106,7 +93,8 @@ static void ext2_close_file(struct file *file)
* @return: the pointer of the group's descriptor
*
*/
-static 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;
@@ -118,7 +106,6 @@ static struct ext2_group_desc *get_group_desc(struct fs_info *fs, uint32_t group
block_num += sb.s_first_data_block + 1;
cs = get_cache_block(fs->fs_dev, block_num);
-
desc = (struct ext2_group_desc *)cs->data + offset;
return desc;
@@ -126,8 +113,6 @@ static struct ext2_group_desc *get_group_desc(struct fs_info *fs, uint32_t group
/**
- * read_inode:
- *
* read the right inode structure to _dst_.
*
* @param: inode_offset, the inode offset within a group;
@@ -138,8 +123,8 @@ static struct ext2_group_desc *get_group_desc(struct fs_info *fs, uint32_t group
*
*/
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)
+ struct ext2_inode *dst, struct ext2_group_desc *desc,
+ block_t *block, uint32_t *offset)
{
struct cache_struct *cs;
struct ext2_inode *inode;
@@ -159,8 +144,6 @@ static void read_inode(struct fs_info *fs, uint32_t inode_offset,
/**
- * open_inode:
- *
* open a file indicated by an inode number in INR
*
* @param : inr, the inode number
@@ -169,7 +152,8 @@ static void read_inode(struct fs_info *fs, uint32_t inode_offset,
* the first 128 bytes of the inode, stores in ThisInode
*
*/
-static 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;
@@ -208,7 +192,7 @@ static struct open_file_t * open_inode(struct fs_info *fs, uint32_t inr, uint32_
static struct ext4_extent_header *
-ext4_find_leaf (struct fs_info *fs, struct ext4_extent_header *eh, block_t block)
+ext4_find_leaf(struct fs_info *fs, struct ext4_extent_header *eh, block_t block)
{
struct ext4_extent_idx *index;
struct cache_struct *cs;
@@ -241,7 +225,8 @@ 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 */
-static 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;
@@ -249,7 +234,7 @@ static block_t linsector_extent(struct fs_info *fs, block_t block, struct ext2_i
block_t start;
leaf = ext4_find_leaf(fs, (struct ext4_extent_header*)inode->i_block, block);
- if (! leaf) {
+ if (!leaf) {
printf("ERROR, extent leaf not found\n");
return 0;
}
@@ -262,8 +247,7 @@ static block_t linsector_extent(struct fs_info *fs, block_t block, struct ext2_i
if (--i < 0) {
printf("ERROR, not find the right block\n");
return 0;
- }
-
+ }
/* got it */
block -= ext[i].ee_block;
@@ -503,9 +487,8 @@ static uint32_t ext2_getfssec(struct file *gfile, char *buf,
* find a dir entry, if find return it or return NULL
*
*/
-static 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)
{
bool have_more;
char *EndBlock = trackbuf + (SecPerClust << SECTOR_SHIFT);;
@@ -595,14 +578,12 @@ static char *do_symlink(struct fs_info *fs, struct open_file_t *file,
/**
- * searchdir:
- *
* Search the root directory for a pre-mangle filename in FILENAME.
*
* @param: filename, the filename we want to search.
*
- * @out : a file pointer, stores in DS:SI (NOTE, DS == 0)
- * @out : file lenght in bytes, stores in eax
+ * @out : a open_file_t structure pointer, stores in file->open_file
+ * @out : file lenght in bytes, stores in file->file_len
*
*/
static void ext2_searchdir(char *filename, struct file *file)
@@ -701,16 +682,12 @@ static void ext2_searchdir(char *filename, struct file *file)
static void ext2_load_config(com32sys_t *regs)
{
char *config_name = "extlinux.conf";
- com32sys_t out_regs;
strcpy(ConfigName, config_name);
*(uint32_t *)CurrentDirName = 0x00002f2e;
regs->edi.w[0] = OFFS_WRT(ConfigName, 0);
- memset(&out_regs, 0, sizeof out_regs);
- call16(core_open, regs, &out_regs);
-
- regs->eax.w[0] = out_regs.eax.w[0];
+ call16(core_open, regs, regs);
#if 0
printf("the zero flag is %s\n", regs->eax.w[0] ? \
@@ -720,15 +697,13 @@ static void ext2_load_config(com32sys_t *regs)
}
-/**
+/*
* init. the fs meta data, return the block size bits.
*/
static int ext2_fs_init(struct fs_info *fs)
{
struct disk *disk = fs->fs_dev->disk;
-#if 0
- printf("super block@: %p\n", &sb);
-#endif
+
/* read the super block */
disk->rdwr_sectors(disk, &sb, 2, 2, 0);
diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c
index 0611caec..4ba43fef 100644
--- a/core/fs/fat/fat.c
+++ b/core/fs/fat/fat.c
@@ -1,16 +1,16 @@
#include <stdio.h>
#include <string.h>
-#include "cache.h"
-#include "core.h"
-#include "disk.h"
+#include <cache.h>
+#include <core.h>
+#include <disk.h>
+#include <fs.h>
#include "fat_fs.h"
-#include "fs.h"
#define ROOT_DIR_WORD 0x002f
/* file structure. This holds the information for each currently open file */
struct open_file_t {
- sector_t file_sector; /* sector pointer ( 0 = structure free ) */
+ sector_t file_sector; /* sector pointer (0 = structure free) */
uint32_t file_bytesleft; /* number of bytes left */
uint32_t file_left; /* number of sectors left */
};
@@ -19,7 +19,6 @@ static struct open_file_t Files[MAX_OPEN];
extern uint8_t SecPerClust;
-
/* the fat bpb data */
static struct fat_bpb fat;
static int FATType = 0;
@@ -51,23 +50,17 @@ static int NameLen;
static struct fs_info *this_fs = NULL;
-/**
- * allocate_file:
- *
- * Allocate a file structure
- *
- * @return: if successful return the file pointer, or return NULL
+/*
+ * Allocate a file structure, if successful return the file pointer, or NULL.
*
*/
static struct open_file_t *allocate_file(void)
{
- struct open_file_t *file;
+ struct open_file_t *file = Files;
int i = 0;
-
- file = Files;
- for (; i < MAX_OPEN; i ++ ) {
- if ( file->file_sector == 0 ) /* found it */
+ for (; i < MAX_OPEN; i ++) {
+ if (file->file_sector == 0) /* found it */
return file;
file ++;
}
@@ -76,9 +69,7 @@ static struct open_file_t *allocate_file(void)
}
-/**
- * alloc_fill_dir:
- *
+/*
* Allocate then fill a file structure for a directory starting in
* sector SECTOR. if successful, return the pointer of filled file
* structure, or return NULL.
@@ -89,7 +80,7 @@ static struct open_file_t *alloc_fill_dir(sector_t sector)
struct open_file_t *file;
file = allocate_file();
- if ( !file )
+ if (!file)
return NULL;
file->file_sector = sector; /* current sector */
@@ -111,19 +102,7 @@ static void vfat_close_file(struct file *file)
}
-/* Deallocates a directory structure */
-/***********
-void close_dir(struct fat_dir_entry *dir)
-{
- if ( dir )
- *(uint32_t*)dir = 0;
-}
-***********/
-
-
-/**
- * getfatsector:
- *
+/*
* check for a particular sector in the FAT cache.
*
*/
@@ -134,14 +113,9 @@ static struct cache_struct *getfatsector(struct fs_info *fs, sector_t sector)
/**
- * nextcluster:
- *
* Advance a cluster pointer in clust_num to the next cluster
- * pointer at in the FAT tables. CF = 0 on return if end of file.
- *
- * @param: clust_num;
- *
- * @return: the next cluster number
+ * pointer at in the FAT tables. return the next cluster number
+ * if success, or return 0 if end of file.
*
*/
static uint32_t nextcluster(struct fs_info *fs, uint32_t clust_num)
@@ -156,8 +130,8 @@ static uint32_t nextcluster(struct fs_info *fs, uint32_t clust_num)
case FAT12:
fat_sector = (clust_num + clust_num / 2) >> SECTOR_SHIFT;
cs = getfatsector(fs, fat_sector);
- offset = (clust_num * 3 / 2) & ( SECTOR_SIZE -1 );
- if ( offset == 0x1ff ) {
+ offset = (clust_num * 3 / 2) & (SECTOR_SIZE -1);
+ if (offset == 0x1ff) {
/*
* we got the end of the one fat sector,
* but we don't got we have(just one byte, we need two),
@@ -171,29 +145,29 @@ static uint32_t nextcluster(struct fs_info *fs, uint32_t clust_num)
} else
next_cluster = *(uint16_t *)(cs->data + offset);
- if ( clust_num & 0x0001 )
+ if (clust_num & 0x0001)
next_cluster >>= 4; /* cluster number is ODD */
else
next_cluster &= 0x0fff; /* cluster number is EVEN */
- if ( next_cluster > 0x0ff0 )
+ if (next_cluster > 0x0ff0)
goto fail;
break;
case FAT16:
fat_sector = clust_num >> (SECTOR_SHIFT - 1);
- offset = clust_num & ( (1 << (SECTOR_SHIFT-1)) -1);
+ offset = clust_num & ((1 << (SECTOR_SHIFT-1)) -1);
cs = getfatsector(fs, fat_sector);
next_cluster = ((uint16_t *)cs->data)[offset];
- if ( next_cluster > 0xfff0 )
+ if (next_cluster > 0xfff0)
goto fail;
break;
case FAT32:
fat_sector = clust_num >> (SECTOR_SHIFT - 2);
- offset = clust_num & ( (1 << (SECTOR_SHIFT-2)) -1);
+ offset = clust_num & ((1 << (SECTOR_SHIFT-2)) -1);
cs = getfatsector(fs, fat_sector);
next_cluster = ((uint32_t *)cs->data)[offset] & 0x0fffffff;
- if ( next_cluster > 0x0ffffff0 )
+ if (next_cluster > 0x0ffffff0)
goto fail;
break;
}
@@ -207,9 +181,7 @@ static uint32_t nextcluster(struct fs_info *fs, uint32_t clust_num)
-/**
- * nextsector:
- *
+/*
* given a sector on input, return the next sector of the
* same filesystem object, which may be the root directory or a
* cluster chain. Returns EOF.
@@ -220,25 +192,25 @@ static sector_t nextsector(struct fs_info *fs, sector_t sector)
sector_t data_sector;
uint32_t cluster;
- if ( sector < DataArea ) {
+ if (sector < DataArea) {
sector ++;
/* if we reached the end of root area */
- if ( sector == DataArea )
+ if (sector == DataArea)
sector = 0; /* return 0 */
return sector;
}
data_sector = sector - DataArea;
- if ( (data_sector+1) & ClustMask ) /* in a cluster */
+ if ((data_sector+1) & ClustMask) /* in a cluster */
return (++sector);
/* got a new cluster */
cluster = nextcluster(fs, (data_sector >> ClustShift) + 2);
- if ( !cluster )
+ if (!cluster )
return 0;
/* return the start of the new cluster */
- sector = ( (cluster - 2) << ClustShift ) + DataArea;
+ sector = ((cluster - 2) << ClustShift) + DataArea;
return sector;
}
@@ -260,7 +232,8 @@ static sector_t nextsector(struct fs_info *fs, sector_t sector)
* @param: sectors
*
*/
-static void __getfssec(struct fs_info *fs, char *buf, struct open_file_t *file, uint32_t sectors)
+static void __getfssec(struct fs_info *fs, char *buf,
+ struct open_file_t *file, uint32_t sectors)
{
sector_t curr_sector = file->file_sector;
sector_t frag_start , next_sector;
@@ -276,13 +249,13 @@ static void __getfssec(struct fs_info *fs, char *buf, struct open_file_t *file,
/* get consective sector count */
con_sec_cnt ++;
sectors --;
- if ( sectors == 0 )
+ if (sectors == 0)
break;
next_sector = nextsector(fs, curr_sector);
- if ( !next_sector )
+ if (!next_sector)
break;
- }while( next_sector == (++curr_sector) );
+ }while(next_sector == (++curr_sector));
#if 0
printf("You are reading data stored at sector --0x%x--0x%x\n",
@@ -293,7 +266,7 @@ static void __getfssec(struct fs_info *fs, char *buf, struct open_file_t *file,
disk->rdwr_sectors(disk, buf, frag_start, con_sec_cnt, 0);
buf += con_sec_cnt << 9;/* adjust buffer pointer */
- if ( !sectors )
+ if (!sectors)
break;
//curr_sector --; /* this is the last sector actually read */
curr_sector = next_sector;
@@ -306,15 +279,12 @@ static void __getfssec(struct fs_info *fs, char *buf, struct open_file_t *file,
/**
- * getfssec:
- *
* get multiple sectors from a file
*
- *
- * @param: buf
- * @param: file
- * @param: sectors
- * @param: have_more
+ * @param: buf, the buffer to store the read data
+ * @param: gfile, the file structure pointer
+ * @param: sectors, number of sectors wanna read
+ * @param: have_more, set one if has more
*
* @return: number of bytes read
*
@@ -326,12 +296,12 @@ static uint32_t vfat_getfssec(struct file *gfile, char *buf, int sectors,
struct open_file_t *file = gfile->open_file;
struct fs_info *fs = gfile->fs;
- if ( sectors > file->file_left )
+ if (sectors > file->file_left)
sectors = file->file_left;
__getfssec(fs, buf, file, sectors);
- if ( bytes_read >= file->file_bytesleft ) {
+ if (bytes_read >= file->file_bytesleft) {
bytes_read = file->file_bytesleft;
*have_more = 0;
} else
@@ -342,9 +312,7 @@ static uint32_t vfat_getfssec(struct file *gfile, char *buf, int sectors,
return bytes_read;
}
-/**
- * mangle_name:
- *
+/*
* Mangle a filename pointed to by src into a buffer pointed to by dst;
* ends on encountering any whitespace.
*
@@ -390,18 +358,12 @@ static void vfat_mangle_name(char *dst, const char *src)
*dst++ = '\0';
}
-/**
- * mangle_dos_name:
- *
+/*
* Mangle a dos filename component pointed to by FILENAME
* into MangleBuf; ends on encountering any whitespace or
* slash.
*
* WARNING: saves pointers into the buffer for longname matchs!
- *
- * @param: filename
- * @param: MangleBuf
- *
*/
/**
* for now, it can't handle this case:
@@ -427,10 +389,10 @@ static void mangle_dos_name(char *MangleBuf, char *filename)
for (i = 0; i < 11; i++) {
c = *src ++;
- if ( (c <= ' ') || (c == '/') )
+ if ((c <= ' ') || (c == '/'))
break;
- if ( c == '.' ) {
+ if (c == '.') {
dst = &MangleBuf[8];
i = 7;
continue;
@@ -438,27 +400,25 @@ static void mangle_dos_name(char *MangleBuf, char *filename)
if (c >= 'a' && c <= 'z')
c -= 32;
- if ( (c == 0xe5) && (i == 11) )
+ if ((c == 0xe5) && (i == 11))
c = 0x05;
*dst++ = c;
}
MangleBuf[12] = '\0';
- while( (*src != '/') && (*src > ' ') )
+ while((*src != '/') && (*src > ' '))
src ++;
NameLen = src - filename;
}
-
-
static void unicode_to_ascii(char *entry_name, uint16_t *unicode_buf)
{
int i = 0;
for (; i < 13; i++) {
- if ( unicode_buf[i] == 0xffff ) {
+ if (unicode_buf[i] == 0xffff) {
entry_name[i] = '\0';
return;
}
@@ -466,9 +426,7 @@ static void unicode_to_ascii(char *entry_name, uint16_t *unicode_buf)
}
}
-/**
- * long_entry_name:
- *
+/*
* get the long entry name
*
*/
@@ -508,8 +466,6 @@ static inline sector_t first_sector(struct fat_dir_entry *dir)
/**
- * search_dos_dir:
- *
* search a specific directory for a pre-mangled filename in
* MangleBuf, in the directory starting in sector SECTOR
*
@@ -524,11 +480,11 @@ static inline sector_t first_sector(struct fat_dir_entry *dir)
* @out: file pointer
* @out: file length (MAY BE ZERO!)
* @out: file attribute
- * @out: dh, clobbered.
*
*/
-static struct open_file_t* search_dos_dir(struct fs_info *fs, char *MangleBuf,
- uint32_t dir_sector, uint32_t *file_len, uint8_t *attr)
+static struct open_file_t*
+search_dos_dir(struct fs_info *fs, char *MangleBuf,
+ uint32_t dir_sector, uint32_t *file_len, uint8_t *attr)
{
struct open_file_t* file;
struct cache_struct* cs;
@@ -542,8 +498,8 @@ static struct open_file_t* search_dos_dir(struct fs_info *fs, char *MangleBuf,
int checksum;
file = allocate_file();
- if ( !file )
- return NULL;
+ if (!file)
+ return NULL;
/*
* Compute the value of a possible VFAT longname
@@ -561,21 +517,21 @@ static struct open_file_t* search_dos_dir(struct fs_info *fs, char *MangleBuf,
/* scan all the entries in a sector */
do {
- if ( dir->name[0] == 0 )
+ if (dir->name[0] == 0)
return NULL; /* Hit directory high water mark */
- if ( dir->attr == 0x0f ) {
+ if (dir->attr == 0x0f) {
/* it's a long name entry */
long_dir = (struct fat_long_name_entry *)dir;
id = long_dir->id;
- if ( id !=VFATNext )
+ if (id !=VFATNext)
goto not_match;
- if ( id & 0x40 ) {
+ if (id & 0x40) {
/*get the initial checksum value*/
VFATCsum = long_dir->checksum;
} else {
- if ( long_dir->checksum != VFATCsum )
+ if (long_dir->checksum != VFATCsum)
goto not_match;
}
@@ -590,8 +546,8 @@ static struct open_file_t* search_dos_dir(struct fs_info *fs, char *MangleBuf,
* if we got the last entry?
* if so, check it, or go on with the next entry
*/
- if ( id == 0 ) {
- if ( strcmp(long_name, NameStart) )
+ if (id == 0) {
+ if (strcmp(long_name, NameStart))
goto not_match;
}
@@ -599,22 +555,22 @@ static struct open_file_t* search_dos_dir(struct fs_info *fs, char *MangleBuf,
} else {
/* it's a short entry */
- if ( dir->attr & 0x08 ) /* ingore volume labels */
+ if (dir->attr & 0x08) /* ingore volume labels */
goto not_match;
/* If we have a long name match, then VFATNext must be 0 */
- if ( !VFATNext ) {
+ if (!VFATNext) {
/*
* we already have a VFAT long name match, however,
* the match is only valid if the checksum matchs.
*/
checksum = get_checksum(dir->name);
- if ( checksum == VFATCsum )
+ if (checksum == VFATCsum)
goto found; /* got a match on long name */
} else {
- if ( strncmp(MangleBuf, dir->name, 11) == 0 )
+ if (strncmp(MangleBuf, dir->name, 11) == 0)
goto found;
}
}
@@ -625,11 +581,11 @@ static struct open_file_t* search_dos_dir(struct fs_info *fs, char *MangleBuf,
next_entry:
dir ++;
- }while ( --entries );
+ }while (--entries);
dir_sector = nextsector(fs, dir_sector);
- }while ( dir_sector ); /* scan another secotr */
+ }while (dir_sector); /* scan another secotr */
found:
*file_len = file->file_bytesleft = dir->file_size;
@@ -642,8 +598,6 @@ static struct open_file_t* search_dos_dir(struct fs_info *fs, char *MangleBuf,
/**
- * searchdir:
- *
* open a file
*
* @param: filename, the file we wanna open
@@ -663,13 +617,13 @@ static void vfat_searchdir(char *filename, struct file *file)
this_fs = file->fs;
dir_sector = CurrentDir;
- if ( *filename == '/' ) {
+ if (*filename == '/') {
dir_sector = RootDir;
if (*(filename + 1) == 0) /* root dir is what we need */
goto found_dir;
}
- while ( *filename ) {
+ while (*filename) {
if (*filename == '/')
filename++; /* skip '/' */
p = filename;
@@ -678,7 +632,7 @@ static void vfat_searchdir(char *filename, struct file *file)
PrevDir = dir_sector;
/* try to find the end */
- while ( (*p > ' ') && (*p != '/') )
+ while ((*p > ' ') && (*p != '/'))
p ++;
if (filename == p) {
@@ -703,13 +657,13 @@ static void vfat_searchdir(char *filename, struct file *file)
dir_sector = PrevDir;
found_dir:
open_file = alloc_fill_dir(dir_sector);
- } else if ( (attr & 0x18) || (file_len == 0) ) {
+ } else if ((attr & 0x18) || (file_len == 0)) {
fail:
file_len = 0;
open_file = NULL;
} else {
open_file->file_bytesleft = file_len;
- open_file->file_left = ( file_len + SECTOR_SIZE -1 ) >> SECTOR_SHIFT;
+ open_file->file_left = (file_len + SECTOR_SIZE -1) >> SECTOR_SHIFT;
}
file->file_len = file_len;
@@ -759,21 +713,21 @@ void vfat_readdir(com32sys_t *regs)/*
cs = get_cache_block(this_fs->fs_dev, sector);
dir = (struct fat_dir_entry *)(cs->data + sec_off);/* resume last position in sector */
- while ( 1 ) {
- if ( dir->name[0] == 0 )
+ while (1) {
+ if (dir->name[0] == 0)
goto fail;
- if ( dir->attr == FAT_ATTR_LONG_NAME ) {
+ if (dir->attr == FAT_ATTR_LONG_NAME) {
/* it's a long name */
long_dir = (struct fat_long_name_entry *)dir;
- if ( long_dir->id & 0x40 ) {
+ if (long_dir->id & 0x40) {
init_id = id = long_dir->id & 0x3f;
id--;
} else {
next_id = (long_dir->id & 0x3f) - 1;
id--;
- if ( id != next_id )
+ if (id != next_id)
goto next_entry;
}
@@ -789,22 +743,22 @@ void vfat_readdir(com32sys_t *regs)/*
} else {
/* it's a short entry */
- if ( !id ) /* we got a long name match */
+ if (!id) /* we got a long name match */
break;
- if ( dir->attr & FAT_ATTR_VOLUME_ID )
+ if (dir->attr & FAT_ATTR_VOLUME_ID)
goto next_entry;
- for( i = 0; i < 8; i ++) {
- if ( dir->name[i] == ' ' )
+ for(i = 0; i < 8; i ++) {
+ if (dir->name[i] == ' ')
break;
*filename++ = dir->name[i];
}
*filename++ = '.';
- for ( i = 8; i < 11; i ++) {
- if ( dir->name[i] == ' ' )
+ for (i = 8; i < 11; i ++) {
+ if (dir->name[i] == ' ')
break;
*filename ++ = dir->name[i];
}
@@ -822,20 +776,20 @@ void vfat_readdir(com32sys_t *regs)/*
dir ++;
entries_left --;
- if ( !entries_left ) {
+ if (!entries_left) {
sector = nextsector(this_fs, sector);
- if ( !sector )
+ if (!sector)
goto fail;
cs = get_cache_block(this_fs->fs_dev, sector);
dir = (struct fat_dir_entry *)cs->data;
}
}
- /* finally , we get what we want */
+ /* finally , we get what we want */
entries_left --;
- if ( !entries_left ) {
+ if (!entries_left) {
sector = nextsector(this_fs, sector);
- if ( !sector )
+ if (!sector)
goto fail;
dir_file->file_bytesleft = 0;
} else
@@ -843,7 +797,7 @@ void vfat_readdir(com32sys_t *regs)/*
dir_file->file_sector = sector;
file.file_sector = sector;
- file.file_bytesleft = (SECTOR_SIZE - (entries_left << DIRENT_SHIFT) ) & 0xffff;
+ file.file_bytesleft = (SECTOR_SIZE - (entries_left << DIRENT_SHIFT)) & 0xffff;
regs->eax.l = dir->file_size;
regs->ebx.l = first_sector(dir);
@@ -887,7 +841,7 @@ static void vfat_load_config(com32sys_t *regs)
if (! (oregs.eflags.l & EFLAGS_ZF))
break;
}
- if ( i == 3 ) {
+ if (i == 3) {
printf("no config file found\n");
return; /* no config file */
}
@@ -929,9 +883,9 @@ static int vfat_fs_init(struct fs_info *fs)
ClustSize = fat.bxSecPerClust << SECTOR_SHIFT;
clust_num = (TotalSectors - DataArea) >> ClustShift;
- if ( clust_num < 4085 )
+ if (clust_num < 4085)
FATType = FAT12;
- else if ( clust_num < 65525 )
+ else if (clust_num < 65525)
FATType = FAT16;
else
FATType = FAT32;
diff --git a/core/fs/iso9660/iso9660.c b/core/fs/iso9660/iso9660.c
index 1d08805b..68d57363 100644
--- a/core/fs/iso9660/iso9660.c
+++ b/core/fs/iso9660/iso9660.c
@@ -1,10 +1,9 @@
#include <stdio.h>
#include <string.h>
-//#include "cache.h"
-#include "core.h"
-#include "disk.h"
+#include <core.h>
+#include <disk.h>
+#include <fs.h>
#include "iso9660_fs.h"
-#include "fs.h"
#define DEBUG 1
@@ -18,7 +17,6 @@ struct open_file_t {
uint32_t file_bytesleft;
uint32_t file_left;
};
-
static struct open_file_t Files[MAX_OPEN];
struct dir_t {
@@ -41,9 +39,7 @@ static char *ISOFileNameEnd = &ISOFileName[64];
*/
static int block_shift;
-/**
- * allocate_file:
- *
+/*
* allocate a file structure
*
*/
@@ -78,9 +74,7 @@ static void iso_close_file(struct file *file)
close_pvt(file->open_file);
}
-/**
- * mangle_name:
- *
+/*
* Mangle a filename pointed to by src into a buffer pointed
* to by dst; ends on encountering any whitespace.
* dst is preserved.
@@ -127,7 +121,7 @@ static void iso_mangle_name(char *dst, const char *src)
}
/**
- * compare the names si and di and report if they are
+ * compare the names de_name and file_name and report if they are
* equal from an ISO 9600 perspective.
*
* @param: de_name, the name from the file system.
@@ -201,8 +195,6 @@ static inline int cdrom_read_sectors(struct disk *disk, void *buf, int block, in
}
/**
- * iso_getfssec:
- *
* Get multiple clusters from a file, given the file pointer.
*
* @param: buf
@@ -238,15 +230,11 @@ static uint32_t iso_getfssec(struct file *gfile, char *buf,
-/**
- * do_search_dir:
- *
+/*
* find a file or directory with name within the _dir_ directory.
*
* the return value will tell us what we find, it's a file or dir?
- * on 1 be dir, 2 be file, 0 be error.
- *
- * res will return the result.
+ * on 1 be dir, 2 be file, 0 be error. res will return the result.
*
*/
static int do_search_dir(struct fs_info *fs, struct dir_t *dir,
@@ -381,9 +369,7 @@ static int do_search_dir(struct fs_info *fs, struct dir_t *dir,
}
-/**
- * iso_searchdir:
- *
+/*
* open a file
*
* searchdir_iso is a special entry point for ISOLINUX only. In addition
@@ -462,13 +448,20 @@ static void iso_searchdir(char *filename, struct file *file)
static void iso_load_config(com32sys_t *regs)
{
char *config_name = "isolinux.cfg";
- com32sys_t out_regs;
+
+#if DEBUG
+ printf("About to load config file...\n");
+#endif
strcpy(ConfigName, config_name);
-
regs->edi.w[0] = OFFS_WRT(ConfigName, 0);
- memset(&out_regs, 0, sizeof out_regs);
- call16(core_open, regs, &out_regs);
+ call16(core_open, regs, regs);
+
+#if DEBUG
+ printf("the zero flag is %s\n", regs->eax.w[0] ?
+ "CLEAR, means we found the config file" :
+ "SET, menas we didn't find the config file");
+#endif
}
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index d03847d3..8ac5b06b 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -9,14 +9,6 @@
#define GPXE 1
static struct open_file_t Files[MAX_OPEN];
-
-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";
-
-static char *tftpprefix_msg = "TFTP prefix: ";
-static char *get_packet_msg = "Getting cached packet ";
-
static int has_gpxe;
static uint8_t uuid_dashes[] = {4, 2, 2, 2, 6, 0};
int HaveUUID = 0;
@@ -89,7 +81,7 @@ static struct open_file_t *allocate_socket(void)
}
/*
- * free socket, socket in SI; return SI = 0, ZF = 1 for convenience
+ * free socket in _file_.
*/
static void free_socket(struct open_file_t *file)
{
@@ -131,7 +123,7 @@ static void lchexbytes(char *dst, const void *src, int count)
}
}
-/**
+/*
* just like the lchexbytes, except to upper-case
*
*/
@@ -151,50 +143,31 @@ static void uchexbytes(char *dst, const void *src, int count)
}
}
-
-
-
/*
- *
- * Tests an IP address in EAX for validity; return with 0 for bad, 1 for good.
+ * Tests an IP address in _ip_ for validity; return with 0 for bad, 1 for good.
* We used to refuse class E, but class E addresses are likely to become
* assignable unicast addresses in the near future.
*
*/
int ip_ok(uint32_t ip)
{
- if (ip == -1) /* Refuse the all-one address */
- goto bad;
- if ((ip & 0xff) == 0) /* Refuse network zero */
- goto bad;
- if ((ip & 0xff) == 0xff) /* Refuse loopback */
- goto bad;
- if ((ip & 0xf0) == 0xe0) /* Refuse class D */
- goto bad;
-
- return 1;
+ if (ip == -1 || /* Refuse the all-one address */
+ (ip & 0xff) == 0 || /* Refuse network zero */
+ (ip & 0xff) == 0xff || /* Refuse loopback */
+ (ip & 0xf0) == 0xe0 ) /* Refuse class D */
+ return 0;
- bad:
- return 0;
+ return 1;
}
-/*********************************************************************
-;
-; gendotquad
-;
-; Take an IP address (in network byte order) in EAX and
-; output a dotted quad string to ES:DI.
-; DI points to terminal null at end of string on exit.
-;
- *********************************************************************/
-/**
- * @param: dst, to store the converted ip string
- * @param: ip, the ip address that needed convert.
- *
- * @return: the ip string length
+/*
+ * Take an IP address (in network byte order) in _ip_ and
+ * output a dotted quad string to _dst_, returns the length
+ * of the dotted quad ip string.
+ *
*/
-int gendotquad(char *dst, uint32_t ip)
+static int gendotquad(char *dst, uint32_t ip)
{
int part;
int i = 0, j;
@@ -273,7 +246,6 @@ static int pxe_call(int opcode, void *data)
}
/**
- *
* Send ACK packet. This is a common operation and so is worth canning.
*
* @param: file, TFTP block pointer
@@ -319,11 +291,10 @@ static int pxe_get_cached_info(int type)
bq_pkt.packettype = type;
bq_pkt.buffersize = 8192;
bq_pkt.buffer[0] = OFFS_WRT(trackbuf, 0);
- bq_pkt.buffer[1] = 0;
-
+ bq_pkt.buffer[1] = 0;
err = pxe_call(PXENV_GET_CACHED_INFO, &bq_pkt);
if (err) {
- printf("%s %04x\n", err_pxefailed, err);
+ printf("PXE API call failed, error %04x\n", err);
kaboom();
}
@@ -360,7 +331,8 @@ static int is_gpxe(char *url)
{
int err;
static __lowmem struct gpxe_file_api_check ac;
- char *gpxe_warning_msg = "URL syntax, but gPXE extensions not detected, tring plain TFTP...\n";
+ char *gpxe_warning_msg =
+ "URL syntax, but gPXE extensions not detected, tring plain TFTP...\n";
if (! is_url(url))
return 0;
@@ -378,11 +350,8 @@ static int is_gpxe(char *url)
if (!has_gpxe)
printf("%s\n", gpxe_warning_msg);
}
-
- if (has_gpxe == 1)
- return 1;
- else
- return 0;
+
+ return has_gpxe == 1;
}
/**
@@ -496,14 +465,7 @@ static void pxe_mangle_name(char *dst, const char *src)
while (i) {
*dst++ = 0;
i--;
- }
-
-#if 0
- printf("the name before mangling: ");
- dump16(src);
- printf("the name after mangling: ");
- dump16((char *)MK_PTR(regs->ds, regs->edi.w[0]));
-#endif
+ }
}
@@ -526,14 +488,9 @@ static char *pxe_unmangle_name(char *dst, const char *src)
}
/*
- *
- ;
- ; Get a fresh packet if the buffer is drained, and we haven't hit
- ; EOF yet. The buffer should be filled immediately after draining!
- ;
- ; expects fs -> pktbuf_seg and ds:si -> socket structure
- ;
-*/
+ * Get a fresh packet if the buffer is drained, and we haven't hit
+ * EOF yet. The buffer should be filled immediately after draining!
+ */
static void fill_buffer(struct open_file_t *file)
{
int err;
@@ -615,14 +572,15 @@ static void fill_buffer(struct open_file_t *file)
* so the server just resent the previous packet.
*/
#if 0
- printf("Wrong packet, wanted %04x, got %04x\n", htons(last_pkt), htons(*(uint16_t *)(data+2)));
+ printf("Wrong packet, wanted %04x, got %04x\n", \
+ htons(last_pkt), htons(*(uint16_t *)(data+2)));
#endif
goto ack_again;
}
/* It's the packet we want. We're also EOF if the size < blocksize */
file->tftp_lastpkt = last_pkt; /* Update last packet number */
- buffersize = pkt.buffersize - 4; /* Skip TFTP header */
+ buffersize = pkt.buffersize - 4; /* Skip TFTP header */
file->tftp_dataptr = file->tftp_pktbuf + 4;
file->tftp_filepos += buffersize;
file->tftp_bytesleft = buffersize;
@@ -659,8 +617,8 @@ static uint32_t pxe_getfssec(struct file *gfile, char *buf,
count <<= TFTP_BLOCKSIZE_LG2;
while (count) {
- fill_buffer(file); /* If we have no 'fresh' buffer, get it */
- if (! file->tftp_bytesleft)
+ fill_buffer(file); /* If we have no 'fresh' buffer, get it */
+ if (!file->tftp_bytesleft)
break;
chunk = count;
@@ -703,21 +661,13 @@ static int fill_tail(char *dst)
}
-/*
- *
- *
- * searchdir:
+/**
+ * Open a TFTP connection to the server
*
- * Open a TFTP connection to the server
+ * @param:filename, the file we wanna open
*
- * On entry:
- * DS:DI = mangled filename
- * If successful:
- * ZF clear
- * SI = socket pointer
- * EAX = file length in bytes, or -1 if unknown
- * If unsuccessful
- * ZF set
+ * @out: open_file_t structure, stores in file->open_file
+ * @ouT: the lenght of this file, stores in file->file_len
*
*/
static void pxe_searchdir(char *filename, struct file *file)
@@ -1037,11 +987,11 @@ static void get_prefix(void)
*(p + 2) = 0; /* Zero-terminate after delimiter */
got_prefix:
- printf("%s%s\n", tftpprefix_msg, PathPrefix);
+ printf("TFTP prefix: %s\n", PathPrefix);
strcpy(CurrentDirName, PathPrefix);
}
- /**
+ /*
* try to load a config file, if found, return 1, or return 0
*
*/
@@ -1071,7 +1021,6 @@ static int try_load(com32sys_t *regs)
*/
static void pxe_load_config(com32sys_t *regs)
{
- extern void no_config(void);
char *cfgprefix = "pxelinux.cfg/";
char *default_str = "default";
char *config_file; /* Pointer to the variable suffix */
@@ -1175,14 +1124,10 @@ static void make_bootif_string(void)
#endif
}
/*
- ;
- ; genipopt
- ;
- ; Generate an ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask>
- ; option into IPOption based on a DHCP packet in trackbuf.
- ; Assumes CS == DS == ES.
- ;
-*/
+ * Generate an ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask>
+ * option into IPOption based on a DHCP packet in trackbuf.
+ *
+ */
static void genipopt(void)
{
char *p = IPOption;
@@ -1245,7 +1190,7 @@ static int is_pxe(const void *buf)
return sum == 0;
}
-/**
+/*
* Just like is_pxe, it checks PXENV+ structure
*
*/
@@ -1269,24 +1214,15 @@ static int is_pxenv(const void *buf)
-/*********************************************************************
-;
-; memory_scan_for_pxe_struct:
-; memory_scan_for_pxenv_struct:
-;
-; If none of the standard methods find the !PXE/PXENV+ structure,
-; look for it by scanning memory.
-;
-; On exit, if found:
-; ZF = 1, ES:BX -> !PXE structure
-; Otherwise:
-; ZF = 0
-;
-; Assumes DS == CS
-; Clobbers AX, BX, CX, DX, SI, ES
-;
- ********************************************************************/
-
+/*
+ * memory_scan_for_pxe_struct:
+ * memory_scan_for_pxenv_struct:
+ *
+ * If none of the standard methods find the !PXE/PXENV+ structure,
+ * look for it by scanning memory.
+ *
+ * return the corresponding pxe structure if found, or NULL;
+ */
static const void *memory_scan(uintptr_t start, int (*func)(const void *))
{
const char *ptr;
@@ -1380,7 +1316,7 @@ static void pxe_init(void)
goto have_pxenv;
/* Found nothing at all !! */
- printf("%s\n", err_nopxe);
+ printf("No !PXE or PXENV+ API found; we're dead...\n");
kaboom();
have_pxenv:
@@ -1442,7 +1378,7 @@ static void udp_init(void)
uo_pkt.sip = MyIP;
err = pxe_call(PXENV_UDP_OPEN, &uo_pkt);
if (err || uo_pkt.status) {
- printf("%s", err_udpinit);
+ printf("Failed to initialize UDP stack ");
printf("%d\n", uo_pkt.status);
kaboom();
}
@@ -1462,20 +1398,19 @@ static void network_init(void)
/*
* Get the DHCP client identifiers (query info 1)
*/
- printf("%s", get_packet_msg);
+ printf("Getting cached packet ");
pkt_len = pxe_get_cached_info(1);
parse_dhcp(pkt_len);
/*
- ; We don't use flags from the request packet, so
- ; this is a good time to initialize DHCPMagic...
- ; Initialize it to 1 meaning we will accept options found;
- ; in earlier versions of PXELINUX bit 0 was used to indicate
- ; we have found option 208 with the appropriate magic number;
- ; we no longer require that, but MAY want to re-introduce
- ; it in the future for vendor encapsulated options.
- */
+ * We don't use flags from the request packet, so
+ * this is a good time to initialize DHCPMagic...
+ * Initialize it to 1 meaning we will accept options found;
+ * in earlier versions of PXELINUX bit 0 was used to indicate
+ * we have found option 208 with the appropriate magic number;
+ * we no longer require that, but MAY want to re-introduce
+ * it in the future for vendor encapsulated options.
+ */
*(char *)&DHCPMagic = 1;
-
/*
* Get the BOOTP/DHCP packet that brought us file (and an IP
@@ -1490,20 +1425,16 @@ static void network_init(void)
*/
MACLen = bp->hardlen > 16 ? 0 : bp->hardlen;
MACType = bp->hardware;
- memcpy(MAC, bp->macaddr, MACLen);
-
+ memcpy(MAC, bp->macaddr, MACLen);
/*
* Get the boot file and other info. This lives in the CACHED_REPLY
* packet (query info 3)
*/
pkt_len = pxe_get_cached_info(3);
- parse_dhcp(pkt_len);
-
+ parse_dhcp(pkt_len);
printf("\n");
-
-
make_bootif_string();
ip_init();
diff --git a/core/isolinux.asm b/core/isolinux.asm
index 09844781..b67bdc19 100644
--- a/core/isolinux.asm
+++ b/core/isolinux.asm
@@ -68,12 +68,6 @@ file_left resd 1 ; Number of sectors left
%endif
%endif
- struc dir_t
-dir_lba resd 1 ; Directory start (LBA)
-dir_len resd 1 ; Length in bytes
-dir_clust resd 1 ; Length in clusters
- endstruc
-
; ---------------------------------------------------------------------------
; BEGIN CODE
; ---------------------------------------------------------------------------
@@ -91,10 +85,6 @@ trackbuf resb trackbufsize ; Track buffer goes here
; is loaded. DO NOT move this to .bss16/.uibss.
section .earlybss
alignb 4
-ISOFileName resb 64 ; ISO filename canonicalization buffer
-ISOFileNameEnd equ $
-CurrentDir resb dir_t_size ; Current directory
-RootDir resb dir_t_size ; Root directory
FirstSecSum resd 1 ; Checksum of bytes 64-2048
ImageDwords resd 1 ; isolinux.bin size, dwords
InitStack resd 1 ; Initial stack pointer (SS:SP)
@@ -1171,18 +1161,8 @@ all_read:
;
; Locate the configuration file
;
-%ifdef DEBUG_MESSAGES
- mov si,dbg_config_msg
- call writemsg
-%endif
-
pm_call load_config
-%ifdef DEBUG_MESSAGES
- mov si,dbg_configok_msg
- call writemsg
-%endif
-
;
; Now we have the config file open. Parse the config file and
; run the user interface.
@@ -1334,21 +1314,8 @@ is_disk_image:
; -----------------------------------------------------------------------------
section .data16
-
-default_str db 'default', 0
-default_len equ ($-default_str)
-boot_dir db '/boot' ; /boot/isolinux
-isolinux_dir db '/isolinux', 0
-config_name db 'isolinux.cfg', 0
err_disk_image db 'Cannot load disk image (invalid file)?', CR, LF, 0
-%ifdef DEBUG_MESSAGES
-dbg_rootdir_msg db 'Root directory at LBA = ', 0
-dbg_isodir_msg db 'isolinux directory at LBA = ', 0
-dbg_config_msg db 'About to load config file...', CR, LF, 0
-dbg_configok_msg db 'Configuration file opened...', CR, LF, 0
-%endif
-
;
; Config file keyword table
;
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 49c81f1e..ed67518f 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -48,24 +48,12 @@ SECTOR_SIZE equ TFTP_BLOCKSIZE
;
; TFTP operation codes
;
-TFTP_RRQ equ htons(1) ; Read request
-TFTP_WRQ equ htons(2) ; Write request
-TFTP_DATA equ htons(3) ; Data packet
TFTP_ACK equ htons(4) ; ACK packet
TFTP_ERROR equ htons(5) ; ERROR packet
-TFTP_OACK equ htons(6) ; OACK packet
;
; TFTP error codes
;
-TFTP_EUNDEF equ htons(0) ; Unspecified error
-TFTP_ENOTFOUND equ htons(1) ; File not found
-TFTP_EACCESS equ htons(2) ; Access violation
-TFTP_ENOSPACE equ htons(3) ; Disk full
-TFTP_EBADOP equ htons(4) ; Invalid TFTP operation
-TFTP_EBADID equ htons(5) ; Unknown transfer
-TFTP_EEXISTS equ htons(6) ; File exists
-TFTP_ENOUSER equ htons(7) ; No such user
TFTP_EOPTNEG equ htons(8) ; Option negotiation failure
;
@@ -86,60 +74,6 @@ vk_append: resb max_cmd_len+1 ; Command line
vk_end: equ $ ; Should be <= vk_size
endstruc
-;
-; BOOTP/DHCP packet pattern
-;
- struc bootp_t
-bootp:
-.opcode resb 1 ; BOOTP/DHCP "opcode"
-.hardware resb 1 ; ARP hardware type
-.hardlen resb 1 ; Hardware address length
-.gatehops resb 1 ; Used by forwarders
-.ident resd 1 ; Transaction ID
-.seconds resw 1 ; Seconds elapsed
-.flags resw 1 ; Broadcast flags
-.cip resd 1 ; Client IP
-.yip resd 1 ; "Your" IP
-.sip resd 1 ; Next server IP
-.gip resd 1 ; Relay agent IP
-.macaddr resb 16 ; Client MAC address
-.sname resb 64 ; Server name (optional)
-.bootfile resb 128 ; Boot file name
-.option_magic resd 1 ; Vendor option magic cookie
-.options resb 1260 ; Vendor options
- endstruc
-
-BOOTP_OPTION_MAGIC equ htonl(0x63825363) ; See RFC 2132
-
-;
-; TFTP connection data structure. Each one of these corresponds to a local
-; UDP port. The size of this structure must be a power of 2.
-; HBO = host byte order; NBO = network byte order
-; (*) = written by options negotiation code, must be dword sized
-;
-; For a gPXE connection, we set the local port number to -1 and the
-; remote port number contains the gPXE file handle.
-;
- struc open_file_t
-tftp_localport resw 1 ; Local port number (0 = not in use)
-tftp_remoteport resw 1 ; Remote port number
-tftp_remoteip resd 1 ; Remote IP address
-tftp_filepos resd 1 ; Bytes downloaded (including buffer)
-tftp_filesize resd 1 ; Total file size(*)
-tftp_blksize resd 1 ; Block size for this connection(*)
-tftp_bytesleft resw 1 ; Unclaimed data bytes
-tftp_lastpkt resw 1 ; Sequence number of last packet (NBO)
-tftp_dataptr resw 1 ; Pointer to available data
-tftp_goteof resb 1 ; 1 if the EOF packet received
- resb 3 ; Currently unusued
- ; At end since it should not be zeroed on socked close
-tftp_pktbuf resw 1 ; Packet buffer offset
- endstruc
-%ifndef DEPEND
-%if (open_file_t_size & (open_file_t_size-1))
-%error "open_file_t is not a power of 2"
-%endif
-%endif
; ---------------------------------------------------------------------------
; BEGIN CODE
@@ -356,11 +290,7 @@ local_boot:
; kaboom: write a message and bail out. Wait for quite a while,
; or a user keypress, then do a hard reboot.
;
- global no_config, kaboom
-; set the no_config kaboom here
-no_config:
- mov si, err_noconfig
- call writestr_early
+ global kaboom
kaboom:
RESET_STACK_AND_SEGS AX
.patch: mov si,bailmsg
@@ -481,8 +411,6 @@ TimeoutTable:
TimeoutTableEnd equ $
section .text16
-
-
;
; unload_pxe:
;
@@ -605,36 +533,10 @@ copyright_str db ' Copyright (C) 1994-'
db ' H. Peter Anvin et al', CR, LF, 0
err_bootfailed db CR, LF, 'Boot failed: press a key to retry, or wait for reset...', CR, LF, 0
bailmsg equ err_bootfailed
-err_nopxe db "No !PXE or PXENV+ API found; we're dead...", CR, LF, 0
-err_pxefailed db 'PXE API call failed, error ', 0
-err_udpinit db 'Failed to initialize UDP stack', CR, LF, 0
-err_noconfig db 'Unable to locate configuration file', CR, LF, 0
-err_damage db 'TFTP server sent an incomprehesible reply', CR, LF, 0
-found_pxenv db 'Found PXENV+ structure', CR, LF, 0
-apiver_str db 'PXE API version is ',0
-pxeentry_msg db '!PXE entry point found (we hope) at ', 0
-pxenventry_msg db 'PXENV+ entry point found (we hope) at ', 0
-viaplan_msg db ' via plan '
-plan db 'A', CR, LF, 0
-trymempxe_msg db 'Scanning memory for !PXE structure... ', 0
-trymempxenv_msg db 'Scanning memory for PXENV+ structure... ', 0
-undi_data_msg db 'UNDI data segment at ',0
-undi_code_msg db 'UNDI code segment at ',0
-len_msg db ' len ', 0
cant_free_msg db 'Failed to free base memory, error ', 0
-notfound_msg db 'not found', CR, LF, 0
-myipaddr_msg db 'My IP address seems to be ',0
-tftpprefix_msg db 'TFTP prefix: ', 0
localboot_msg db 'Booting from local disk...', CR, LF, 0
-trying_msg db 'Trying to load: ', 0
-default_str db 'default', 0
syslinux_banner db CR, LF, 'PXELINUX ', VERSION_STR, ' ', DATE_STR, ' ', 0
-cfgprefix db 'pxelinux.cfg/' ; No final null!
-cfgprefix_len equ ($-cfgprefix)
-; This one we make ourselves
-bootif_str db 'BOOTIF='
-bootif_str_len equ $-bootif_str
;
; Config file keyword table
;
@@ -672,74 +574,18 @@ old_api_unload:
; PXE query packets partially filled in
;
section .bss16
- global pxe_bootp_query_pkt, pxe_udp_write_pkt
- global pxe_udp_open_pkt, pxe_udp_read_pkt
-pxe_bootp_query_pkt:
-.status: resw 1 ; Status
-.packettype: resw 1 ; Boot server packet type
-.buffersize: resw 1 ; Packet size
-.buffer: resw 2 ; seg:off of buffer
-.bufferlimit: resw 1 ; Unused
-
-pxe_udp_open_pkt:
-.status: resw 1 ; Status
-.sip: resd 1 ; Source (our) IP
-
pxe_udp_close_pkt:
.status: resw 1 ; Status
-pxe_udp_write_pkt:
-.status: resw 1 ; Status
-.sip: resd 1 ; Server IP
-.gip: resd 1 ; Gateway IP
-.lport: resw 1 ; Local port
-.rport: resw 1 ; Remote port
-.buffersize: resw 1 ; Size of packet
-.buffer: resw 2 ; seg:off of buffer
-
pxe_udp_read_pkt:
-.status: resw 1 ; Status
-.sip: resd 1 ; Source IP
-.dip: resd 1 ; Destination (our) IP
-.rport: resw 1 ; Remote port
-.lport: resw 1 ; Local port
-.buffersize: resw 1 ; Max packet size
-.buffer: resw 2 ; seg:off of buffer
-
-%if GPXE
-
- section .data16
- global gpxe_file_api_check
-gpxe_file_api_check:
-.status: dw 0 ; Status
-.size: dw 20 ; Size in bytes
-.magic: dd 0x91d447b2 ; Magic number
-.provider: dd 0
-.apimask: dd 0
-.flags: dd 0
-
- section .bss16
- global gpxe_file_read, gpxe_get_file_size
- global gpxe_file_open
-
-gpxe_file_open:
-.status: resw 1 ; Status
-.filehandle: resw 1 ; FileHandle
-.filename: resd 1 ; seg:off of FileName
-.reserved: resd 1
-
-gpxe_get_file_size:
-.status: resw 1 ; Status
-.filehandle: resw 1 ; FileHandle
-.filesize: resd 1 ; FileSize
-
-gpxe_file_read:
-.status: resw 1 ; Status
-.filehandle: resw 1 ; FileHandle
-.buffersize: resw 1 ; BufferSize
-.buffer: resd 1 ; seg:off of buffer
+.status: resw 1 ; Status
+.sip: resd 1 ; Source IP
+.dip: resd 1 ; Destination (our) IP
+.rport: resw 1 ; Remote port
+.lport: resw 1 ; Local port
+.buffersize: resw 1 ; Max packet size
+.buffer: resw 2 ; seg:off of buffer
-%endif ; GPXE
;
; Misc initialized (data) variables