How to create a kind of log file?
How to create a kind of log file?
Hi, I started this thread because I didn't see anything that I am looking for. So what I am after is this. How to create a file? A barebone minimum list to achieve this really.
I just want to create some kind of log file to store everything printed on screen into a file by the kernel(I got sick of my little bochs screen display + like to create something by the kernel.).
I think it is to do with the file system. I am intended to implement it if possible.
It will be great if anyone could point me to a right direction.
Any helps and advise are welcome~ Thank you
I just want to create some kind of log file to store everything printed on screen into a file by the kernel(I got sick of my little bochs screen display + like to create something by the kernel.).
I think it is to do with the file system. I am intended to implement it if possible.
It will be great if anyone could point me to a right direction.
Any helps and advise are welcome~ Thank you
Re:How to create a kind of log file?
You can use the E9 hack feature of Bochs to write to the command prompt terminal [and presumeably to the log file for Bochs] which should be good enough (Once your kernel is mature you won't actually need a boot log - at least not by default).
To create a file you will basically need a filesystem driver and a device driver, the filesystem driver needs to use the device driver to read the drive, manipulate the filesystem (create bookkeeping information) and then finally write the actual data to disk.
Of course this would be inappropriate in a microkernel and I have no idea how to overcome that (since you need the filesystem server before you can access the disk so if something goes wrong beforehand then there is no way to access the disk)
To create a file you will basically need a filesystem driver and a device driver, the filesystem driver needs to use the device driver to read the drive, manipulate the filesystem (create bookkeeping information) and then finally write the actual data to disk.
Of course this would be inappropriate in a microkernel and I have no idea how to overcome that (since you need the filesystem server before you can access the disk so if something goes wrong beforehand then there is no way to access the disk)
Re:How to create a kind of log file?
You could do this without a filesystem too.
Load your bootsector to sector 0 and your kernel at 1 to whatever it needs.
Then after your kernel at some fixed sector have that be the location of the log file. then you could view it using something.....
I would not recommend this. Sounds like more effort that figuering out the FAT file system.
Load your bootsector to sector 0 and your kernel at 1 to whatever it needs.
Then after your kernel at some fixed sector have that be the location of the log file. then you could view it using something.....
I would not recommend this. Sounds like more effort that figuering out the FAT file system.
Re:How to create a kind of log file?
I doubt this, since you would need to do this to get FAT to work anyway (the fundamental actual writing to disk part), FAT adds the need to also maintain bookkeeping information which isn't necessary in raw mode.Tora OS wrote:I would not recommend this. Sounds like more effort that figuering out the FAT file system.
Re:How to create a kind of log file?
Well, you want to read the log file... which would make using a filesystem a good idea, or you end up writing a log-reading tool too...
But is the on-file log file actually necessary at all?
Suggestion: Write log messages to some memory area. (Easier than either RAW or FAT.) In your keyboard handler code, add a check for whether the key pressed is... uh... say, F12. If it is, print the first 20 messages from the log buffer. If F12 is pressed again, print the next 20 messages from the log buffer. If the buffer is full, roll around.
All in all, that should be much less effort to code. Kind of like a "dmesg | less" in kernel space. Perhaps that's already sufficient for your debugging needs?
If not, you can still consider adding to the roll-around code a couple of lines writing that buffer to file / RAW first...
But is the on-file log file actually necessary at all?
Suggestion: Write log messages to some memory area. (Easier than either RAW or FAT.) In your keyboard handler code, add a check for whether the key pressed is... uh... say, F12. If it is, print the first 20 messages from the log buffer. If F12 is pressed again, print the next 20 messages from the log buffer. If the buffer is full, roll around.
All in all, that should be much less effort to code. Kind of like a "dmesg | less" in kernel space. Perhaps that's already sufficient for your debugging needs?
If not, you can still consider adding to the roll-around code a couple of lines writing that buffer to file / RAW first...
Every good solution is obvious once you've found it.
Re:How to create a kind of log file?
Great~! Solar idea is probably the simpler to implement and good for to start now.
I wanted to search for information to make my kernel product some sort of output(a file). At the same time, I was annoyed by the size of the bochs display and ended up having to pause it so often, so I came up with this idea really. So its not really that necessary.
I didn't understand about the bootsector suggestion from Tora OS, it does some hard...
What AR suggests its what I am looking for also. I want my kernel to be a microkernel. but as AR suggested I need a file server before I can do all that.
(I don't understand what a file server should contain apart from the drivers. Does it have any extra feature to make it a server like communications or else?)
Would it be possible if I have these driver in side the kernel first like a monolithickernel, then later move it outside the kernel?
My understand about this topic is not very deep. Please help~
I wanted to search for information to make my kernel product some sort of output(a file). At the same time, I was annoyed by the size of the bochs display and ended up having to pause it so often, so I came up with this idea really. So its not really that necessary.
I didn't understand about the bootsector suggestion from Tora OS, it does some hard...
What AR suggests its what I am looking for also. I want my kernel to be a microkernel. but as AR suggested I need a file server before I can do all that.
(I don't understand what a file server should contain apart from the drivers. Does it have any extra feature to make it a server like communications or else?)
Would it be possible if I have these driver in side the kernel first like a monolithickernel, then later move it outside the kernel?
My understand about this topic is not very deep. Please help~
Re:How to create a kind of log file?
Not to mention faster in execution, and avoiding problems arising with doing file I/O in kernel space (huge latencies if your kernel is not preemptable, completely screwed-up output if it is preemptable).chaisu chase wrote: Great~! Solar idea is probably the simpler to implement and good for to start now.
Tora basically suggested ignoring "file system" concerns and working on hardcoded disk sectors. That's something you can consider early on, but as I said you would need a "log reading" tool - and it would be very hard on any real floppy since you'd write to the same sectors over and over and over...I didn't understand about the bootsector suggestion from Tora OS, it does some hard...
The very concept of a microkernel is to have most services running in user space, as server process. You don't tell the kernel to save your file, you tell the file server to do it. For your problem that's not viable, because it would assume your kernel is already "fully" functional.What AR suggests its what I am looking for also. I want my kernel to be a microkernel. but as AR suggested I need a file server before I can do all that.
(I don't understand what a file server should contain apart from the drivers. Does it have any extra feature to make it a server like communications or else?)
Until you don't have a file server process, you'll need the driver in the kernel to achieve anything. And you need some code to actually load the file server process.Would it be possible if I have these driver in side the kernel first like a monolithickernel, then later move it outside the kernel?
Every good solution is obvious once you've found it.
Re:How to create a kind of log file?
If u are using bochs
u can use the
record 'filename'
command which actually records the
console output to the file.
u can use the
record 'filename'
command which actually records the
console output to the file.
Re:How to create a kind of log file?
Correct, but many errors only show up on real hardware - and that is when you really need that output to not scroll past faster than you can read.
Every good solution is obvious once you've found it.
Re:How to create a kind of log file?
Thanks solar, a file server process it is. I think i will look it up and find out more. Yeah, I was thinking about having everything in the kernel space to start with.
Can I ask, how do you perform the record filename command? I can't find this option in my bochs2.1.1.
Thanks for the help and advices~
Can I ask, how do you perform the record filename command? I can't find this option in my bochs2.1.1.
Thanks for the help and advices~
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:How to create a kind of log file?
alternatively, if you need deep inspection of that log for a real system (e.g. the problem ends with memory corruption or general system failure), you may want to connect 2 PCs with a null-modem cable and send the log over the serial port to the second PC that will store and analyse the log ...