Tring to make an OS, need help.

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.
Tora OS

Re:Tring to make an OS, need help.

Post by Tora OS »

thoover wrote: Can any one tell me how to draw pitzles on the screen in assembly? >:)

frogive my spelling I am in a little hurry.
you need to switch a video mode to a graphics mode. forinstance i belive 12 h is would work. then you would use a colour attribute for each pixel starting at A000:0000.

unfortantly all my old real mode os stuff is on one of the hard drives sitting on my desk, so i dont have any good code examples to show you.
thoover

Re:Tring to make an OS, need help.

Post by thoover »

Can I use any name for a boot sector?

And can I load EXE or COM files on that boot sector GLneo gave me? :-\
GLneo

Re:Tring to make an OS, need help.

Post by GLneo »

name wont mater use makeboot to copy the "flat bianary" kernel right after the boot sector
thoover

Re:Tring to make an OS, need help.

Post by thoover »

need more info on useing pixels. ???
thoover

Re:Tring to make an OS, need help.

Post by thoover »

That Boot sector is not working do you have one compiled I can use?
GLneo

Re:Tring to make an OS, need help.

Post by GLneo »

yes, as for pixels in your kernel:

Code: Select all

mov ah, 0x00
al, 0x13
int 0x10
then your in graphicts mode, to plot a pixel in "c":

Code: Select all

char *vga = 0xA0000;

void plot_pixel(int x, int y, char color)
{
    vga[(y * 320) + x] = color;
}
if your not using "c" you should

p.s. the compiled version is encluded, it does go to pmode so you should be able to use gcc(greatest compiler ever!!!)

p.p.s. it is not a text file it wont let me upload ".bin's"

p.p.p.s. might i suggest:
http://osdever.net/bkerndev/index.php it is the best os startor tutrial ever, follow it step by step and from there you can do enything
Tora OS

Re:Tring to make an OS, need help.

Post by Tora OS »

GLneo wrote: p.p.p.s. might i suggest:
http://osdever.net/bkerndev/index.php it is the best os startor tutrial ever, follow it step by step and from there you can do enything

I aggree. That tutorial is about the best you will find. The steps are easy to follow and understand and the code is well commented.
thoover

Re:Tring to make an OS, need help.

Post by thoover »

The compiled version did not work. Can that boot sector code be used on a floppy disk? ??? If not that is whats wrong.

I am using MS Window's compilers so I don't know if GCC is for windows if I'm not mistaken it will only work for Linex.
Tora OS

Re:Tring to make an OS, need help.

Post by Tora OS »

THoover wrote: The compiled version did not work. Can that boot sector code be used on a floppy disk? ??? If not that is whats wrong.
That's the whole point...to have it run on a floppy. It *should* work.

THoover wrote:I am using MS Window's compilers so I don't know if GCC is for windows if I'm not mistaken it will only work for Linex.
No...there are ports of GCC for windows. DJGPP is my personal favourite.

http://www.delorie.com/djgpp/
GLneo

Re:Tring to make an OS, need help.

Post by GLneo »

djgpp is the best for windows/dos deving, it is kinda hard to start becouse you have to unpack ".zip's" and set enviroment verialbles, but in the long run it is obviously the best.

also stop mailing me, post stuff (i never read my mail so kinda pointless)

also convert my bootsector.txt to bootsector.bin then use partcopy: http://my.execpc.com/~geezer/johnfine/pcopy02.zip
then goto dos prompt and type:

Code: Select all

partcopy bootsector.bin 0 200 -f0 0

WARNING partcopy used in properly can be deadly ;)
then load the kernel you made with djgpp like this:

Code: Select all

partcopy "your_kernel.name" 0 "size_of_your_kernel" -f0 200
p.s. test your os with bochs it tells you whats wrong wend your kenel dies and if it dies you wont lose your computer!!! ;)
thoover

Re:Tring to make an OS, need help.

Post by thoover »

Any link directly to a GCC compiler that will work for these drivers:

SOUND
MOUSE
USB
CD\DVD DRIVE (optional)
AR

Re:Tring to make an OS, need help.

Post by AR »

You would be better off with a dedicated cross compiler on Cygwin, DJGPP is designed for DPMI DOS Apps, it can produce flat binaries but unless you are going to hack your own executable format by manually creating headers in a flat binary you will need a cross compiler eventually.

It sounds as though you really haven't got a clue what you're doing, I suggest you read some materials on how existing OS' work like Linux and Windows. You also need to understand how the ABI works in your language and compiler of choice (calling convention), also understanding how system calls work in user space will be useful later. This is of course assuming you have at least some experience with C/C++ software development.
thoover

Re:Tring to make an OS, need help.

Post by thoover »

I am very good with C, ok with c++, and very bad with assimbly, but I need better compilers mine must not work too well.
Tora OS

Re:Tring to make an OS, need help.

Post by Tora OS »

THoover wrote: Any link directly to a GCC compiler that will work for these drivers:

SOUND
MOUSE
USB
CD\DVD DRIVE (optional)
You have to write your own drives inorder to do that, lad. Personally I have no clue how to write any of those, so I am not a good source for examples.

Definatly find some tutorials on your basic kernel. What you should do is build a basic kernel with some basic drivers (VGA, Floppy) and build on to it. Next you might add Tasks and memory management. and then keyboard, and then mouse, and then start adding the more advanced things such as CD drives and USB, and Sound.
GLneo

Re:Tring to make an OS, need help.

Post by GLneo »

any gcc will let you wright anything you want, what i think you dont understand is YOU HAVE TO EVERYTHING, thats what make OS's such a great project, sad to say the bios will not have built in support for opengl :P but i can help you with mouse
NOTE: you will have to have irq handlers:

Code: Select all

int x = 0, y = 0;
static volatile int button[3] = {0, 0, 0};
unsigned char data[3];

void ps2_mouse()
{
    data[0] = inport60();
    data[1] = inport60();
    data[2] = inport60();
    if ((data[0] & 0x01) != button[0])
    {
        button[0] ^= 1;
        if (button[0]) left_button_down(x, y);
        else left_button_up(x, y);
    }
    if ((data[0] & 0x04) != button[1])
    {
        button[1] ^= 1;
        if (button[1]) middle_button_down(x, y);
        else middle_button_up(x, y);
    }
    if ((data[0] & 0x02) != button[2])
    {
        button[2] ^= 1;
        if (button[2]) right_button_down(x, y);
        else right_button_up(x, y);
    }
    if (data[0] & 0x10)
        x += (int)((256 - data[1]) * -1);
    else
        x += (int)data[1];
    if (data[0] & 0x20)
        y += (int) (256 - data[2]);
    else
        y += (int)(data[2] * -1);
    if (y > 184) y = 184;
    else if (y < 0) y = 0;
    if (x > 311) x = 311;
    else if (x < 0) x = 0;
}

void init_ps2_mouse()
{
    int x;
    unsigned char data_read;
    for(x = 0; x < 5; x++)
    {
        outport64(0xA7);                    //reset every thing
        outport64(0xA8);
        outport64(0xD4);
        outport60(0xF5);
        data_read = inport60();             //    did it 
        if (data_read != 0xFA) continue;    //    work ?
        outport64(0xD4);
        outport60(0xFF);
        data_read = inport60();             //    did it
        if (data_read != 0xFA) continue;    //    work ?
        data_read = inport60();             //    did the self-
        if (data_read != 0xAA) continue;    //    test work ?
        mouse_type = inport60();
        outport64(0xD4);
        outport60(0xE6);
        data_read = inport60();             //    did it
        if (data_read != 0xFA) continue;    //    work ?
/*
        outport64(0xD4);
        outport60(0xF3);
        data_read = inport60();             //    did it
        if (data_read != 0xFA) continue;    //    work ?
        outport60(210);
        data_read = inport60();             //    did it
        if (data_read != 0xFA) continue;    //    work ?
*/
        outport64(0x20);                    
        data_read = inport60();             //
        data_read |= 0x02;                  // 
        outport64(0x60);                    //    get it to report data
        outport60(data_read);               //
        outport64(0xD4);                    //
        outport60(0xF4);
        data_read = inport60();             //    did it
        if (data_read != 0xFA) continue;    //    work ?
        break;
    }
}

void left_button_down(int x, int y)
{
}

void left_button_up(int x, int y)
{
}

void right_button_down(int x, int y)
{
    reboot();
}

void right_button_up(int x, int y)
{
}

void middle_button_down(int x, int y)
{
}

void middle_button_up(int x, int y)
{
}
first call "init_ps2_mouse" then every time irq12 fires(or for you you could just keep calling it in a loop) ps2_mouse it will update x and y, what you do with them i dont know??? you can fill the buttons with what ever you want ;)
Post Reply