annotate include/fs.h @ 99:2a0aa3efc228

The shell script will now theroretically load the program into memory, will not run it. The shell script loads a program into memory and displays the address but as of now does not jump to it (though it does display the address it would jump to) Added a memset function Added a python script (credit for its writing to Jeff) that sets up a filesystem
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sat, 14 May 2011 19:40:18 -0400
parents 7962969a9abd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
1 #include <std.h>
69
19000e354e36 Start working on redoing the error codes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 67
diff changeset
2 #include <error.h>
56
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
3
51
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
4 #ifndef __FS_H
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
5 #define __FS_H
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
6
56
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
7 #define CACHESPACE 1 //percentage of heap to use for the FS Cache
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
8 #define FNAMELEN 28 //How long the filenames are
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
9 #define FSBLKSIZE 1024
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
10 #define DSKBLKSIZE 512
61
5e1d4b26c2ef Added the ability to write an arbitrary block of data to some file
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 57
diff changeset
11 #define MAXBLOCKS 248
70
3b73044b740f I think I have just about all of the FS code using errcodes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 69
diff changeset
12 #define FSMAGICNUM 0x42420374
67
9816d3510467 Redid the interface for handling file data
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 64
diff changeset
13 #define DEPBLK (FSBLKSIZE / sizeof(Direntry)) //director entries per block
56
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
14
70
3b73044b740f I think I have just about all of the FS code using errcodes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 69
diff changeset
15 #define ERR_FSBLKREADFAIL mkError(MODFS, BLKREADFAIL, ERROR)
3b73044b740f I think I have just about all of the FS code using errcodes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 69
diff changeset
16
51
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
17 struct SUPERBLOCK {
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
18 u32 magic; // == 0x42420374
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
19 u32 root_inode; // the disk block containing the root inode
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
20 u32 nblocks; // number of block on the disk
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
21 u32 _pad[253]; // unused (should be '\0' filled)
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
22 };
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
23 typedef struct SUPERBLOCK Superblock;
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
24
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
25 struct INODE {
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
26 u32 size; // file length in bytes
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
27 u32 _pad0; // unused (should be 0)
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
28 u64 ctime; // creation time stamp
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
29 u64 mtime; // last modification time stamp
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
30 u16 nblocks; // number of data blocks in this file
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
31 u16 _pad1; // unused (should be 0)
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
32 u32 _pad2; // unused (should be 0)
61
5e1d4b26c2ef Added the ability to write an arbitrary block of data to some file
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 57
diff changeset
33 u32 blocks[MAXBLOCKS]; // file block ptrs
51
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
34 };
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
35 typedef struct INODE Inode;
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
36
55
25be3895c62a The filesystem now supports a much better cache system
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 54
diff changeset
37 struct FSBLK {
56
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
38 u8 blocks[FSBLKSIZE];
55
25be3895c62a The filesystem now supports a much better cache system
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 54
diff changeset
39 };
25be3895c62a The filesystem now supports a much better cache system
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 54
diff changeset
40 typedef struct FSBLK FSBlk;
25be3895c62a The filesystem now supports a much better cache system
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 54
diff changeset
41
25be3895c62a The filesystem now supports a much better cache system
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 54
diff changeset
42 struct DSKBLK {
56
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
43 u8 blocks[DSKBLKSIZE];
55
25be3895c62a The filesystem now supports a much better cache system
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 54
diff changeset
44 };
25be3895c62a The filesystem now supports a much better cache system
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 54
diff changeset
45 typedef struct DSKBLK DskBlk;
25be3895c62a The filesystem now supports a much better cache system
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 54
diff changeset
46
51
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
47 struct DIRENTRY { //32 bytes
56
8fef616405c0 Got rid of magical numbers, improved comments
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 55
diff changeset
48 char fname[FNAMELEN];
51
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
49 u32 inode;
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
50 };
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
51 typedef struct DIRENTRY Direntry;
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
52
69
19000e354e36 Start working on redoing the error codes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 67
diff changeset
53 ErrCode init_fs(u32 devnum, u64 __memsize);
19000e354e36 Start working on redoing the error codes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 67
diff changeset
54 ErrCode getFInfo(u32 n, void* de);
19000e354e36 Start working on redoing the error codes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 67
diff changeset
55 ErrCode lookupFile(char *fname, u32 *fid);
74
36e6fc4a0487 Added the ability to create a new file
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 72
diff changeset
56 ErrCode makeFile(char *fname, u32 *fid);
80
2fb2138d8c83 Added the ability to delete a file
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 76
diff changeset
57 ErrCode deleteFile(u32 fid);
76
6538d7c45ad8 I may have append working, got rid of setFileData
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 74
diff changeset
58 ErrCode fileAppend(u32 fid, void *data, u32 length);
88
7962969a9abd Created fileWrite to write data to a postition within a file, fileAppend uses fileWrite.
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 80
diff changeset
59 ErrCode fileWrite(u32 fid, void *data, u32 length, u32 offset);
69
19000e354e36 Start working on redoing the error codes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 67
diff changeset
60 ErrCode getFileSize(u32 fid, u32 *size);
70
3b73044b740f I think I have just about all of the FS code using errcodes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 69
diff changeset
61 ErrCode getFileData(u32 fid, void *ptr);
51
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
62 void printFname(char *name);
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
63 void getFname(char *fname);
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
64 int fnameCmp(const char *a, const char *b);
eda059d74100 Started to librarize (is that a word) the filesystem
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff changeset
65
70
3b73044b740f I think I have just about all of the FS code using errcodes
Jonathan Pevarnek <pevarnj@gmail.com>
parents: 69
diff changeset
66 #endif //__FS_H