EliteOS (If I am going soemthing wrong, please let me know)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
OpteronELITE

EliteOS (If I am going soemthing wrong, please let me know)

Post by OpteronELITE »

Read if you want (Or scroll down to "EliteOS:"):
Hello, I just got the Internet at my house. :D I have 26.4 kbps Dial-Up. Right now, I know Pascal, Delphi, C++, Visual basic (yuck). I have downloaded DJGPP for my Win XP Pro system. :) This system is awesome! I have been programming for years in Turbo Pascal and some Turbo C. My 486 was wicked slow. After working for two years, I finally bought a competent PC. :) The Windows is a little differant from the MS-DOS 5 I have been using. I am pretty good at writing Windows apps in Delphi (Mostly email clients and word processor stuff). I would like to write an operating system.

Why I want to write an OS:
I am not writing an OS simply to get credit. I have a genuine interest in learning more about how the PC works. If I just wanted to furbish an OS, I would take FreeDOS and run a GUI over it written in VBDOS. But if I did this, I would not learn about how the PC functions. I have read many articles about OS development, studied the source code of FDOS (Mini little 16-Bit non-protected mode Assembly-based OS that can load flat binaries), and I have created a boot loader in Assembly.

EliteOS:
EliteOS is an OS in teh first stages...
*Loads boot sector code (Written by me and Assembled via NASM)
*Loads 32-Bit protected mode kernel (Written in C) that displays a message and halts.
*Probes RAM

Now I need to create the memory manager.
Remember, this is for educational purposes. However, I will give out my OS as FREEWARE. Thank you for your time. Any suggestions/scrutiny are welcome. My email is filled with SPAM, and my SPAM filter is not finished. So please leave comments in thsi thread. ;D
OpteronELITE

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by OpteronELITE »

Sorry I spelled the topic wrong. I can touch type, but sometimes I encounter typographical errors. :-[
OpteronELITE

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by OpteronELITE »

Please do not disrespect and over scrutinize me just because my profile reads "Rookie". It took me a very long time to buy this computer and I learn fast. Please treat me equally.
bkilgore

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by bkilgore »

Hey, don't worry about it. Mine still says rookie too. But I decided not to worry about what other people think about how experienced I am just by how long I've been a member of this site, and instead just try to learn as much as I can and help out when I have a handle on the subject being discussed. Rookie? HAH! ;)
OpteronELITE

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by OpteronELITE »

My source:

#define WHITE_TXT 0x07 // white on black text

void k_clear_screen();
unsigned int k_printf(char *message, unsigned int line);


k_main() // like main in a normal C program
{
???k_clear_screen();
???k_printf("TW-DOS for 32-Bit x86\nVersion 1.0\n\nCopyright 2003 Techware Corporation\n\nInitializing memory manager...", 0);
k_initmemman();
};

void k_clear_screen() // clear the entire text screen
{
???char *vidmem = (char *) 0xb8000;
???unsigned int i=0;
???while(i < (80*25*2))
???{
??????vidmem=' ';
??????i++;
??????vidmem=WHITE_TXT;
??????i++;
???};
};

unsigned int k_printf(char *message, unsigned int line) // the message and then the line #
{
???char *vidmem = (char *) 0xb8000;
???unsigned int i=0;

???i=(line*80*2);

???while(*message!=0)
???{
??????if(*message=='\n') // check for a new line
??????{
?????????line++;
?????????i=(line*80*2);
?????????*message++;
??????} else {
?????????vidmem=*message;
?????????*message++;
?????????i++;
?????????vidmem=WHITE_TXT;
?????????i++;
??????};
???};

???return(1);
};

void K_initmemman(void)
{
???register ULONG *mem;
???ULONG???mem_count, a;
???USHORT???memkb;
???UCHAR???irq1, irq2;
???ULONG???cr0;

???/* save IRQ's */
???irq1=inb(0x21);
???irq2=inb(0xA1);

???/* kill all irq's */
???outb(0x21, 0xFF);
???outb(0xA1, 0xFF);

???mem_count=0;
???memkb=0;

???// store a copy of CR0
???__asm__ __volatile("movl %%cr0, %%eax":"=a"(cr0))::"eax");

???// invalidate the cache
???// write-back and invalidate the cache
???__asm__ __volatile__ ("wbinvd");

???// plug cr0 with just PE/CD/NW
???// cache disable(486+), no-writeback(486+), 32bit mode(386+)
???__asm__ __volatile__("movl %%eax, %%cr0", :: "a" (cr0 | 0x00000001 | 0x40000000 | 0x20000000) : "eax");

???do
???{
??????memkb++;
??????mem_count+=1024*1024;
??????mem=(ULONG*)mem_count;

??????a=*mem;

??????*mem=0x55AA55AA;
??????
??????// the empty asm calls tell gcc not to rely on whats in its registers
??????// as saved variables (this gets us around GCC optimisations)
??????asm("":::"memory");
??????if(*mem!=0x55AA55AA)
?????????mem_count=0;
??????else
??????{
?????????*mem=0xAA55AA55;
?????????asm("":::"memory");
?????????if(*mem!=0xAA55AA55)
????????????mem_count=0;
??????}

??????asm("":::"memory");
??????*mem=a;
???}while(memkb<4096 && mem_count!=0);

???__asm__ __volatile__("movl %%eax, %%cr0", :: "a" (cr0) : "eax");

???mem_end=memkb<<20;
???mem=(ULONG*)0x413;
???bse_end=((*mem)&0xFFFF)<<6;

???outb(0x21, irq1);
???outb(0xA1, irq2);
k_memman(mem_count);
}


void k_memman(char *message, unsigned int line) // Memory Manager
{

};







Thsi is my kernel, but now that it counts memory, I need a memory manager. :( The file system is FAT, Where can I learn about creating a memory manager? Is it okay to use Windows XP Professional as a development platform? I have lots of old Pentium 1's I can test my OS on. :)
Intel Macintosh Man

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by Intel Macintosh Man »

I'll help!

For one thing your printf function needs rewritten to perl/glibcc standards.

First, what's the k_ for? Second, the char message needs to be an array as big as possible to hold larger strings. Then we call intk_printf (i know forgot the k) to pass the line number. Also, the 3rd line could be optimized by passing the address to char and merging it with line 4. Since we already initiated i, we dont need line*80*2 -- it is pointless since it already went to int line from k_printf. Then we remove the loop because its basicly a rehash of the if statement. Also, the memory manager is used to make up for the lost code. Futher but obvious optimizations are performed later though no explaination is required.

unsigned int printf(char message[999999999999])
{
intk_printf(unsigned int line);
char = "0xb8000", i = 0;

if(*message=='\n' && malloc('/0') && free()) // check for a new line
{

// Saves RAM!!!
free();
free();
free();
free();

line == line + 1;
i==line--line-1 x 80(to the 2nd power);
malloc(*message++);
} else {
vidmem[i -- line-1x80++]==char;
*char++;

// Reorder the i++s to group them.

i++;
i++;
char[videoram]=0xb8000=WHITE_TXT;

};
};

free(message++[99999999999999999999999999])
return(k_printf("PRINTF SUCCESSFUL!!!!!!!!!!!!"));
};

Forgive me if I'm slightly wrong with this -- I am still learning PASCAL myself.
OpteronELITE

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by OpteronELITE »

I wrote an operating system in Visual Basic! :D
OpteronELITE

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by OpteronELITE »

This is what I need help with - What do I do with Malloc() and Free() ? I need some help, not someone that thnks C = Pascal. ???
beyond infinity lazy

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by beyond infinity lazy »

first, you're welcome, gosh! :-)

second, take a look at tim robinsons memory management texts. they should give you plenty of hints about what to do. And for you are an experienced programmer (i take you by your word) there shall not be any problem for you to deduce how to code it from the text.

third: there is a section called quick linkz. Just drop an eye on it, you might be overwhelmed about the bunch of info to be found in that thread. :)

regarding that guy: take it with a grain of salt.
bkilgore

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by bkilgore »

I just have one thing to say about that post.

LOL!
bkilgore

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by bkilgore »

Oh yeah, one other thing:

who on earth has that much free time on their hands?
Tim

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by Tim »

Intel Macintosh Man: That has to be the strangest function I've ever seen. :)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by Pype.Clicker »

Intel Macintosh Man wrote: I'll help!

unsigned int printf(char message[999999999999])
Whaat's that for a stuff ? the message is larger than addressable ram !? for sure no compiler will allow this. Better use a message pointer instead of char msg[any_size].
Forgive me if I'm slightly wrong with this -- I am still learning PASCAL myself.
You're completely wrong, imho. passing non-sense parameters (what's that "malloc(*msg++)" for ?), initializing stuff with completely unappropriate stuff (char* could receive the string "0xB8000", but that wouldn't create a pointer to video memory in any way. char video="0xB8000" is just another syntax error)

We forgive you, but only if you forgive me when i ask people not to give the slighest credit to your printf code ...

I can just suggest you to go through some C tutorials asap (because what you typed wasn't pascal at all :) )
bkilgore

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by bkilgore »

I hope that you're being ironic as well, Pype.Clicker :)
OpteronELITE

Re:EliteOS (If I am going soemthing wrong, please let me kno

Post by OpteronELITE »

I am unable to understand how to implement teh specifications in http://osdev.neopages.net/tutorials/memory1.php. I have no idea how! ??? Some code or some links to tutorials that will help me learn hwo to implement these specificatiosn would help. Thank you. Also, please take a look at teh code I posted above. (Not Intel Mac Man's code)
Post Reply