Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
18 June, 2013, 08:38:20 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: KnightOS Filesystem Specification 2.x -  (Read 1119 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
SirCmpwn
Guest
« on: 08 March, 2011, 01:56:53 »
+1

Attached is the KnightOS Filesytem Specification 2.0, or KFS.  Please review it and tell me if you have any suggestions, questions, or other ideas.  Version 2.1 is coming soon, with more information specific to it's implementation in KnightOS.
You may feel free to use this in your own 3rd party OS project (hell, you can use it in a first party project, if TI's watching Wink)

Also, at the moment, this requires two swap sectors on the TI-83+ BE.  If anyone can think of a better way, please tell me about it.

* KFS_2.0.pdf (613.7 KB - downloaded 93 times.)
« Last Edit: 08 March, 2011, 19:01:23 by SirCmpwn » Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 08:20:57
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50600


Total Post Ratings: +2634

View Profile WWW
« Reply #1 on: 08 March, 2011, 02:03:37 »
0

I unfortunately am not familiar with assembly and that low level stuff, but it seems well explained from what I could gather. Smiley
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
graphmastur
King Graphmastur
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 02 February, 2013, 08:34:45
Date Registered: 03 June, 2010, 21:15:55
Posts: 2262


Total Post Ratings: +60

View Profile
« Reply #2 on: 08 March, 2011, 02:20:26 »
0

Just an idea that I was talking to you about in IRC.  If say page 6 is a FAT table (starts with 0xF0), and page 5 has a file that starts with the byte 0xF0, then you get problems.  I suggest something like 0xF1 or something at least to show you that it is FST.  (Actually, I would do 0xF1 for the FAT and 0xF0 for FST)
Logged

SirCmpwn
Guest
« Reply #3 on: 08 March, 2011, 02:32:58 »
0

That's a good point, I'll add a page identifier for FST pages as well.
Logged
SirCmpwn
Guest
« Reply #4 on: 08 March, 2011, 06:45:53 »
+1

Okay, here is the revised spec.

* KFS_2.1.pdf (544.14 KB - downloaded 100 times.)
Logged
christop
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 13 April, 2013, 04:04:55
Date Registered: 26 February, 2011, 19:58:44
Location: Arizona, USA
Posts: 87

Total Post Ratings: +20

View Profile
« Reply #5 on: 08 March, 2011, 08:44:04 »
0

I noticed that Garbage Dir has ID 0x01 and Directory has ID 0xFE. For deleting a directory or file, is the idea to mark it as deleted by clearing some of the bits in the ID? If so, you won't be able to get an ID of 0x01 by clearing some bits from 0xFE, since bit 0 is already clear in 0xFE. For deleted directory you could use the ID 0x02 instead.

Also, the way the swapping is done is pretty wasteful. It wears down FlashROM at least twice as fast as needed, and takes twice as long too. The way I would do it is to use a floating swap page rather than a fixed swap page. What this means is, instead of copying a page to the swap page and then back to the original page, copy a page to the swap page and then make the old page the new swap page.

To implement this you might have to use virtual page numbers. The first byte of each real page can contain the virtual page number for that page. So, for example, if real page 5 is virtual page 9, then all references to page 9 (say, a file entry with the file contents on page 9) will read from or write to the real page number 5. When you need to swap that page, then you can move the whole virtual page to the swap page easily and make real page 5 the new swap page. This adds a little bit of overhead but gives you much better performance overall.

Additionally, for a little bit of protection against incomplete page erases, you could add a few bytes (a magic value like "KFS") to the beginning/end of a page after it is erased. If your routines read a page that doesn't contain that magic value, then you know that the page wasn't erased properly. Erase the page and write the magic value (and virtual page number) to it.

The rest of the spec looks decent, but it is kind of a shame that only one writable stream can be open at a time. It's cool to see that it supports nested directories and long file names, though.

Good luck with this project!
Logged

Christopher Williams
SirCmpwn
Guest
« Reply #6 on: 08 March, 2011, 15:59:19 »
0

Thanks for pointing out the directory problem.  I hate using hex for that kind of thing, I always make a mistake like that.
As for virtual pages, it sounds like a great idea to start.  However, it would get pretty inefficient, pretty fast.  Imagine you're several GCs into the usage of the filesystem.  The virtual pages end up completely different then the normal ones.  When looking for file entries, or reading from a stream, crossing page boundaries becomes very slow - you'd have to swap through every physical page until you find the virtual one you need.  That worries me, since you already need to search all entries to find the last file added.  It would be even worse for garbage collection.  Plus, the flash chip is a tough puppy.  I've only ever heard of one calculator's flash dying.
Logged
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: Today at 05:24:14
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2737


Total Post Ratings: +376

View Profile
« Reply #7 on: 08 March, 2011, 18:05:30 »
0

Thanks for pointing out the directory problem.  I hate using hex for that kind of thing, I always make a mistake like that.
As for virtual pages, it sounds like a great idea to start.  However, it would get pretty inefficient, pretty fast.  Imagine you're several GCs into the usage of the filesystem.  The virtual pages end up completely different then the normal ones.  When looking for file entries, or reading from a stream, crossing page boundaries becomes very slow - you'd have to swap through every physical page until you find the virtual one you need.  That worries me, since you already need to search all entries to find the last file added.  It would be even worse for garbage collection.  Plus, the flash chip is a tough puppy.  I've only ever heard of one calculator's flash dying.
Are files allowed to cross sector boundaries? If not, you could go with virtual sectors, and crossing pages can still be done in a sequential manner.

Edit:
Also, I see a problem with directories being 0xFE and garbage directories being 0x01. You can't set bit 0, right?
Edit2:
Oops, that was already mentioned Tongue
Edit3:
Now that I look closer, files can be >65536 bytes large, so never mind. Ignore this entire post Big smile
« Last Edit: 08 March, 2011, 18:10:37 by calc84maniac » Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
SirCmpwn
Guest
« Reply #8 on: 08 March, 2011, 18:40:32 »
0

Nice Smiley
Yes, a single file may take up the entire calculator's memory if you wanted.
Logged
Goplat
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: Yesterday at 02:17:42
Date Registered: 08 December, 2009, 13:17:47
Posts: 289

Total Post Ratings: +77

View Profile
« Reply #9 on: 08 March, 2011, 18:50:27 »
0

Thanks for pointing out the directory problem.  I hate using hex for that kind of thing, I always make a mistake like that.
As for virtual pages, it sounds like a great idea to start.  However, it would get pretty inefficient, pretty fast.  Imagine you're several GCs into the usage of the filesystem.  The virtual pages end up completely different then the normal ones.  When looking for file entries, or reading from a stream, crossing page boundaries becomes very slow - you'd have to swap through every physical page until you find the virtual one you need.
Could you keep a copy of the virtual->physical mapping as a table in RAM? With a 1-byte entry per 64kB sector, it should only take 32 bytes.
Logged

Numquam te deseram; numquam te deficiam; numquam circa curram et te desolabo
Numquam te plorare faciam; numquam valedicam; numquam mendacium dicam et te vulnerabo
christop
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 13 April, 2013, 04:04:55
Date Registered: 26 February, 2011, 19:58:44
Location: Arizona, USA
Posts: 87

Total Post Ratings: +20

View Profile
« Reply #10 on: 08 March, 2011, 18:50:35 »
0

As for virtual pages, it sounds like a great idea to start.  However, it would get pretty inefficient, pretty fast.  Imagine you're several GCs into the usage of the filesystem.  The virtual pages end up completely different then the normal ones.  When looking for file entries, or reading from a stream, crossing page boundaries becomes very slow - you'd have to swap through every physical page until you find the virtual one you need.
You can scan the pages at boot time and keep a table in RAM to map virtual pages to real pages. This can be as simple as an array of bytes, the size being determined by the number of Flash pages (how many pages are there anyway? 32?). To find the real page number for a given virtual page number, just use the virtual page number as an index into the array, and read the byte at that position. That byte is the real page number. When you swap pages (as in, use the floating swap page), you just have to update a couple of bytes in the array.

If you align your array on a 256-byte boundary, the code to translate virtual to real page numbers can be this simple (note: I haven't tested this code):

1
2
3
4
ld h,virtual_page_table/256
ld l,a  ; a is the virtual page number
ld a,(hl) ; now a is the real page number

You would want to add some bounds checking on the virtual page number and such in a real system, of course.

EDIT: curses! Goplat beat me by 8 seconds!
« Last Edit: 08 March, 2011, 18:51:46 by christop » Logged

Christopher Williams
SirCmpwn
Guest
« Reply #11 on: 08 March, 2011, 18:59:03 »
0

Thanks for clarifying your point.  I think that I'll use the current system in this version, look into virtual pages for 3.0.  I'm definitely interested in the idea, but it's just not on the time table right now.
« Last Edit: 08 March, 2011, 19:01:14 by SirCmpwn » Logged
graphmastur
King Graphmastur
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 02 February, 2013, 08:34:45
Date Registered: 03 June, 2010, 21:15:55
Posts: 2262


Total Post Ratings: +60

View Profile
« Reply #12 on: 13 March, 2011, 22:12:31 »
0

Virtual pages do sound interesting. How's 2.2 going?
Logged

SirCmpwn
Guest
« Reply #13 on: 13 March, 2011, 22:13:03 »
0

Fine, and it's pretty much done.  I just want to get it implemented in KnightOS before releasing it.
Logged
graphmastur
King Graphmastur
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 02 February, 2013, 08:34:45
Date Registered: 03 June, 2010, 21:15:55
Posts: 2262


Total Post Ratings: +60

View Profile
« Reply #14 on: 13 March, 2011, 22:18:30 »
0

Fine, and it's pretty much done.  I just want to get it implemented in KnightOS before releasing it.
MMK, that's actually even better.  I can't wait!  Well, I guess I could wait since I'll have to wait, but... You get the idea.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.322 seconds with 32 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.