7 /* The this fs pointer */
8 struct fs_info *this_fs;
13 void load_config(com32sys_t *regs)
15 this_fs->fs_ops->load_config(regs);
18 void mangle_name(com32sys_t *regs)
20 char *src = (char *)MK_PTR(regs->ds, regs->esi.w[0]);
21 char *dst = (char *)MK_PTR(regs->es, regs->edi.w[0]);
23 this_fs->fs_ops->mangle_name(dst, src);
27 void unmangle_name(com32sys_t *regs)
33 void getfssec(com32sys_t *regs)
41 sectors = regs->ecx.w[0];
42 buf = (char *)MK_PTR(regs->es, regs->ebx.w[0]);
43 file.open_file = MK_PTR(regs->ds, regs->esi.w[0]);
46 bytes_read = this_fs->fs_ops->getfssec(file.fs, buf, file.open_file, sectors, &have_more);
48 /* if we reach the EOF, set the si to be NULL */
52 regs->ecx.l = bytes_read;
56 void searchdir(com32sys_t *regs)
58 char *filename = (char *)MK_PTR(regs->ds, regs->edi.w[0]);
62 printf("filename: %s\n", filename);
65 memset(&file, 0, sizeof file);
68 this_fs->fs_ops->searchdir(filename, &file);
69 regs->esi.w[0] = OFFS_WRT(file.open_file, 0);
70 regs->eax.l = file.file_len;
72 regs->eflags.l &= ~EFLAGS_ZF;
74 regs->eflags.l |= EFLAGS_ZF;
78 * well, I find that in the diskstart.inc, there's no room fow us to
79 * get the edd check result, so we implement a new one here.
81 uint8_t detect_edd(uint8_t device_num)
83 com32sys_t iregs, oregs;
85 /* Sending int 13h func 41h to query EBIOS information */
86 memset(&iregs, 0, sizeof iregs);
87 memset(&oregs, 0, sizeof oregs);
89 /* Get EBIOS support */
90 iregs.eax.w[0] = 0x4100;
91 iregs.ebx.w[0] = 0x55aa;
92 iregs.edx.b[0] = device_num;
93 iregs.eflags.b[0] = 0x3; /* CF set */
95 __intcall(0x13, &iregs, &oregs);
97 /* Detecting EDD support */
98 if (!(oregs.eflags.l & EFLAGS_CF) &&
99 oregs.ebx.w[0] == 0xaa55 && (oregs.ecx.b[0] & 1))
106 * initialize the device structure
108 void device_init(struct device *dev, uint8_t device_num, sector_t offset)
110 dev->device_number = device_num;
111 dev->part_start = offset;
113 dev->type = detect_edd(device_num);
116 * check if we use cache or not, for now I just know ISO fs
117 * does not use the cache, and I hope the USE_CACHE can detect
121 if ( USE_CACHE(dev->device_number) ) {
122 /* I can't use __lowmem here, 'cause it will cause the error:
123 "auxseg/lowmem region collides with xfer_buf_seg" */
124 //static __lowmem char cache_buf[65536];
125 dev->cache_data = core_cache_buf;
126 dev->cache_size = sizeof core_cache_buf;
128 dev->cache_data = NULL;
133 void dump_dev(struct device *dev)
135 printf("device type:%s\n", dev->type ? "CHS" : "EDD");
136 printf("cache_data: %p\n", dev->cache_data);
137 printf("cache_head: %p\n", dev->cache_head);
138 printf("cache_block_size: %d\n", dev->cache_block_size);
139 printf("cache_entries: %d\n", dev->cache_entries);
140 printf("cache_size: %d\n", dev->cache_size);
145 * initialize the device structure;
146 * set up the vfs fs structure;
147 * invoke the fs-specific init function;
148 * finally, initialize the cache
151 void fs_init(com32sys_t *regs)
154 struct fs_ops *ops = (struct fs_ops*)regs->eax.l;
156 device_init(&dev, regs->edx.b[0], regs->ecx.l);
158 /* set up the fs stucture */
159 fs.fs_name = ops->fs_name;
164 /* invoke the fs-specific init code */
165 blk_shift = fs.fs_ops->fs_init();
167 /* initialize the cache */
169 cache_init(&dev, blk_shift);