-#include "core.h"
-#include "cache.h"
+/*
+ * core/cache.c: A simple LRU-based cache implementation.
+ *
+ */
+
#include <stdio.h>
#include <string.h>
+#include "core.h"
+#include "cache.h"
-/**
- * Each CachePtr contains:
- * - Block pointer
- * - LRU previous pointer
- * - LRU next pointer
- * - Block data buffer address
- *
- * The cache buffer are pointed to by a cache_head structure.
- */
-
-/**
- * cache_init:
- *
- * Initialize the cache data structres.
- * regs->eax.l stores the block size(in bits not bytes)
+/*
+ * Initialize the cache data structres. the _block_size_shift_ specify
+ * the block size, which is 512 byte for FAT fs of the current
+ * implementation since the block(cluster) size in FAT is a bit big.
*
*/
void cache_init(struct device *dev, int block_size_shift)
}
-/**
- * get_cache_block:
- *
+/*
* Check for a particular BLOCK in the block cache,
* and if it is already there, just do nothing and return;
- * otherwise load it and updata the relative cache
- * structre with data pointer.
- *
- * it's a test version for my start of merging extlinux into core.
- * and after I have figured out how to handle the relations between
- * rm and pm, c and asm, we call call it from C file, so no need
- * com32sys_t *regs any more.
- *
- * I just found that I was tring to do a stupid thing!
- * I haven't change the fs code to c, so for now the cache is based
- * on SECTOR SIZE but not block size. While we can fix it easily by
- * make the block size be the sector size.
- *
- * @return: the data stores at gs:si
+ * otherwise load it from disk and updata the LRU link.
*
*/
struct cache_struct* get_cache_block(struct device *dev, block_t block)
}
-/**
+/*
* Just print the sector, and according the LRU algorithm,
* Left most value is the most least secotr, and Right most
* value is the most Recent sector. I see it's a Left Right Used
#include <string.h>
#include <stdbool.h>
#include <klibc/compiler.h>
-#include "core.h"
-#include "fs.h"
-#include "disk.h"
+#include <core.h>
+#include <fs.h>
+#include <disk.h>
#define RETRY_COUNT 6
char *tptr;
size_t chunk, freeseg;
int sector_shift = disk->sector_shift;
- uint32_t xlba = lba + disk->part_start; /* Truncated LBA (CHS is << 2 TB) */
+ uint32_t xlba = lba + disk->part_start; /* Truncated LBA (CHS is << 2 TB) */
uint32_t t;
uint16_t c, h, s;
com32sys_t ireg, oreg;
disk->rdwr_sectors(disk, buf, block * sec_per_block, sec_per_block, 0);
}
-static void dump_disk(struct disk *disk)
-{
- printf("drive number: 0x%x\n", disk->disk_number);
- printf("disk type: %s(%d)\n", disk->type ? "EDD" : "CHS", disk->type);
- printf("sector size: %d(%d)\n", disk->sector_size, disk->sector_shift);
- printf("h: %d\ts: %d\n", disk->h, disk->s);
- printf("offset: %d\n", disk->part_start);
- printf("%s\n", disk->rdwr_sectors == edd_rdwr_sectors ? "EDD_RDWR_SECTORS" :
- "CHS_RDWR_SECTORS");
- printf("--------------------------------\n");
- printf("disk->rdwr_sectors@: %p\n", disk->rdwr_sectors);
- printf("edd_rdwr_sectors @: %p\n", edd_rdwr_sectors);
- printf("chs_rdwr_sectors @: %p\n", chs_rdwr_sectors);
-}
struct disk *disk_init(uint8_t devno, bool cdrom, sector_t part_start,
uint16_t bsHeads, uint16_t bsSecPerTrack)
disk.part_start = part_start;
disk.rdwr_sectors = ebios ? edd_rdwr_sectors : chs_rdwr_sectors;
-#if 0
- dump_disk(&disk);
-#endif
return &disk;
}
return &dev;
}
-
-
-/* debug function */
-static void dump_dev(struct device *dev)
-{
- printf("device type:%s\n", dev->disk->type ? "EDD" : "CHS");
- printf("drive number: 0x%x\n", dev->disk->disk_number);
- printf("cache_data: %p\n", dev->cache_data);
- printf("cache_head: %p\n", dev->cache_head);
- printf("cache_block_size: %d\n", dev->cache_block_size);
- printf("cache_entries: %d\n", dev->cache_entries);
- printf("cache_size: %d\n", dev->cache_size);
-}
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
-#include "fs.h"
-#include "cache.h"
+#include <fs.h>
+#include <cache.h>
/* The currently mounted filesystem */
struct fs_info *this_fs = NULL;
* set up the vfs fs structure;
* initialize the device structure;
* invoke the fs-specific init function;
- * finally, initialize the cache
+ * finally, initialize the cache if we need one
*
*/
void fs_init(com32sys_t *regs)
disk->rdwr_sectors(disk, buf, sector, sector_cnt, 0);
}
-/**
- * getfssec:
- *
+/*
* Get multiple sectors from a file
*
* Alought we have made the buffer data based on block size,
* sectors (then can be multiple blocks) is what the function
* do. So, let it be based on sectors.
*
- * This function can be called from C function, and either from
- * ASM function.
- *
- * @param: ES:BX(of regs), the buffer to store data
- * @param: DS:SI(of regs), the pointer to open_file_t
- * @param: CX(of regs), number of sectors to read
- *
- * @return: ECX(of regs), number of bytes read
- *
*/
static uint32_t ext2_getfssec(struct file *gfile, char *buf,
int sectors, bool *have_more)
-/**
- * find_dir_entry:
- *
- * find a dir entry, if find return it or return NULL
+/*
+ * find a dir entry, return it if found, or return NULL.
*
*/
static struct ext2_dir_entry*
}
-/**
- * close_file:
- *
+/*
* Deallocates a file structure
*
*/
/*
* open a file
*
- * searchdir_iso is a special entry point for ISOLINUX only. In addition
- * to the above, searchdir_iso passes a file flag mask in AL. This is
- * useful for searching for directories.
+ * searchdir_iso is a special entry point for ISOLINUX only.
*
* well, it's not like the searchidr function in EXT fs or FAT fs; it also
* can read a diretory.(Just thought of mine, liu)
}
/*
+ * parse_dhcp
*
- ;
- ; parse_dhcp
- ;
- ; Parse a DHCP packet. This includes dealing with "overloaded"
- ; option fields (see RFC 2132, section 9.3)
- ;
- ; This should fill in the following global variables, if the
- ; information is present:
- ;
- ; MyIP - client IP address
- ; server_ip - boot server IP address
- ; net_mask - network mask
- ; gate_way - default gateway router IP
- ; boot_file - boot file name
- ; DNSServers - DNS server IPs
- ; LocalDomain - Local domain name
- ; MAC_len, MAC - Client identifier, if MAC_len == 0
- ;
- ; This assumes the DHCP packet is in "trackbuf".
- ;
-*/
+ * Parse a DHCP packet. This includes dealing with "overloaded"
+ * option fields (see RFC 2132, section 9.3)
+ *
+ * This should fill in the following global variables, if the
+ * information is present:
+ *
+ * MyIP - client IP address
+ * server_ip - boot server IP address
+ * net_mask - network mask
+ * gate_way - default gateway router IP
+ * boot_file - boot file name
+ * DNSServers - DNS server IPs
+ * LocalDomain - Local domain name
+ * MAC_len, MAC - Client identifier, if MAC_len == 0
+ *
+ * This assumes the DHCP packet is in "trackbuf".
+ *
+ */
void parse_dhcp(int pkt_len)
{
struct bootp_t *dhcp = (struct bootp_t *)trackbuf;