I want to build an OS on windows

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
SiliconOS
Posts: 17
Joined: Sun Feb 14, 2021 12:41 am

I want to build an OS on windows

Post by SiliconOS »

The reason is Windows cannot compile source code to elf.
I try mingw, cygwin and etc.
But they cannot compile to elf!
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: I want to build an OS on windows

Post by alexfru »

Use WSL (on Win10).

Or maybe some toolchain that can produce ELFs (for example, my Smaller C compiler produces assembly that's assembled with NASM/YASM or FASM into ELF object files, which can then be linked into a variety of executables, from ELFs and PEs to DOS EXEs).
I'd say it's not too important, whether its ELFs or PEs. a.out's will work too.
User avatar
AndrewAPrice
Member
Member
Posts: 2300
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: I want to build an OS on windows

Post by AndrewAPrice »

You'll need a cross compiler (a compiler that produces binaries for a system other than the host OS.)

See: https://wiki.osdev.org/GCC_Cross-Compiler

There are even a few prebuilt cross compilers for Windows at the bottom.
My OS is Perception.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: I want to build an OS on windows

Post by bzt »

Or you could simply use PE for your OS. Using ELF isn't mandatory. BOOTBOOT can load PE and ELF kernels equally for example.

Cheers,
bzt
SiliconOS
Posts: 17
Joined: Sun Feb 14, 2021 12:41 am

Re: I want to build an OS on windows

Post by SiliconOS »

bzt wrote:Or you could simply use PE for your OS. Using ELF isn't mandatory. BOOTBOOT can load PE and ELF kernels equally for example.

Cheers,
bzt
So, how I can use PE for my OS?(The Hyperon System Software)
SiliconOS
Posts: 17
Joined: Sun Feb 14, 2021 12:41 am

Re: I want to build an OS on windows

Post by SiliconOS »

SiliconOS wrote:
bzt wrote:Or you could simply use PE for your OS. Using ELF isn't mandatory. BOOTBOOT can load PE and ELF kernels equally for example.

Cheers,
bzt
So, how I can use PE for my OS?(The Hyperon System Software)
I decided to use Pascal and Assembly to write the OS
rdos
Member
Member
Posts: 3297
Joined: Wed Oct 01, 2008 1:55 pm

Re: I want to build an OS on windows

Post by rdos »

I use the OpenWatcom compiler. It can create images for other OSes, although you need to adapt the runtime library for it. OTOH, you need to do this with GCC too.
SiliconOS
Posts: 17
Joined: Sun Feb 14, 2021 12:41 am

Re: I want to build an OS on windows

Post by SiliconOS »

rdos wrote:I use the OpenWatcom compiler. It can create images for other OSes, although you need to adapt the runtime library for it. OTOH, you need to do this with GCC too.
I decided to use Pascal and ASM to write this OS.It's GUI-only, so it could more difficult to draw(The HyperDraw) the UI and etc.
sj95126
Member
Member
Posts: 151
Joined: Tue Aug 11, 2020 12:14 pm

Re: I want to build an OS on windows

Post by sj95126 »

I build my 64-bit ELF kernel under cygwin. It's pretty straight forward, all you need to do is compile gcc and binutils as cross-build tools for the x86_64-elf target.

If it helps, here's exactly how I built the tools:

Code: Select all

export PREFIX=/usr/local/x86_64-elf
export TARGET=x86_64-elf
export PATH="$PREFIX/bin:$PATH"

cd binutils-build
../binutils-2.34/configure --target=x86_64-elf --prefix=/usr/local/x86_64-elf --with-sysroot --disable-nls --disable-werror
make ; make install

cd gcc-build
../gcc-9.3.0/configure --target=x86_64-elf --prefix=/usr/local/x86_64-elf --disable-nls --enable-languages=c --without-headers
make all-gcc ; make all-target-libgcc
make install-gcc ; make install-target-libgcc
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: I want to build an OS on windows

Post by bzt »

SiliconOS wrote:I decided to use Pascal and ASM to write this OS.It's GUI-only, so it could more difficult to draw(The HyperDraw) the UI and etc.
There's a Pascal kernel example in the repo, you can start from there. I've used Lazarus fpc under Linux, but it is said to be working on windows too.

As for the GUI, the loader sets up a linear framebuffer for you, which is technically a pixel buffer, so any library that can use pixels should work without a problem. Otherwise you have to write the code yourself: start with drawing primitives: draw a box, a rectangle, a circle, a line, etc. (Note: the example I've liked provides "Procedure Puts(s : PChar);" to demonstrate how to draw text using PSF2 fonts with Pascal, you can use that). Then build widgets using those: buttons, checkboxes, selectboxes, etc. So far pretty straightforward. Then finally (and this is the hardest) implement a windowing system.

If you would use C, then I would say try nuklear, or some other simple to port GUI libraries. Not sure about Pascal though, I guess there must be similar projects. This looks promising because it uses SDL, so should be straightforward to port (SDL window is using exactly the same kind of pixelbuffer like the linear framebuffer). This might be harder to port, because it seems to have a lot more dependencies, but looks much better.

Cheers,
bzt
SiliconOS
Posts: 17
Joined: Sun Feb 14, 2021 12:41 am

Re: I want to build an OS on windows

Post by SiliconOS »

sj95126 wrote:I build my 64-bit ELF kernel under cygwin. It's pretty straight forward, all you need to do is compile gcc and binutils as cross-build tools for the x86_64-elf target.

If it helps, here's exactly how I built the tools:

Code: Select all

export PREFIX=/usr/local/x86_64-elf
export TARGET=x86_64-elf
export PATH="$PREFIX/bin:$PATH"

cd binutils-build
../binutils-2.34/configure --target=x86_64-elf --prefix=/usr/local/x86_64-elf --with-sysroot --disable-nls --disable-werror
make ; make install

cd gcc-build
../gcc-9.3.0/configure --target=x86_64-elf --prefix=/usr/local/x86_64-elf --disable-nls --enable-languages=c --without-headers
make all-gcc ; make all-target-libgcc
make install-gcc ; make install-target-libgcc
Oh, I want to build for x86_64bit pascal
SiliconOS
Posts: 17
Joined: Sun Feb 14, 2021 12:41 am

Re: I want to build an OS on windows

Post by SiliconOS »

bzt wrote:
SiliconOS wrote:I decided to use Pascal and ASM to write this OS.It's GUI-only, so it could more difficult to draw(The HyperDraw) the UI and etc.
There's a Pascal kernel example in the repo, you can start from there. I've used Lazarus fpc under Linux, but it is said to be working on windows too.

As for the GUI, the loader sets up a linear framebuffer for you, which is technically a pixel buffer, so any library that can use pixels should work without a problem. Otherwise you have to write the code yourself: start with drawing primitives: draw a box, a rectangle, a circle, a line, etc. (Note: the example I've liked provides "Procedure Puts(s : PChar);" to demonstrate how to draw text using PSF2 fonts with Pascal, you can use that). Then build widgets using those: buttons, checkboxes, selectboxes, etc. So far pretty straightforward. Then finally (and this is the hardest) implement a windowing system.

If you would use C, then I would say try nuklear, or some other simple to port GUI libraries. Not sure about Pascal though, I guess there must be similar projects. This looks promising because it uses SDL, so should be straightforward to port (SDL window is using exactly the same kind of pixelbuffer like the linear framebuffer). This might be harder to port, because it seems to have a lot more dependencies, but looks much better.

Cheers,
bzt
I think this write by ASM and pascal(Because it is a OS GUI Library)
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: I want to build an OS on windows

Post by bzt »

SiliconOS wrote:I think this write by ASM and pascal(Because it is a OS GUI Library)
I'm not entirely sure what you're asking. All my links are for Pascal, and a kernel shouldn't be a GUI Library at all. Check out the links I gave you:

- mykernel/pas is a minimal "Hello World" kernel written in Pascal. I've used the FreePascal (fpc) compiler for that (known to work under Windows too, supports both ELF and PE). The example uses PSF2 fonts to draw text on the framebuffer (pixel based graphics mode).

- SimpleGUI is a minimal FreePascal GUI library, written for SDL so should be straightforward to port to framebuffer (just remove SDL_Surface, replace
SDL_Surface.pixels with PDword(@fb),
SDL_Surface.w with bootboot.fb_width,
SDL_Surface.h with bootboot.fb_height, and
SDL_Surface.pitch with bootboot.fb_scanline and you're good to go).

- fpGUI is a fully featured GUI library written in FreePascal, although might be more difficult to port as it has more dependencies. But it has a HOW-TO port doc.

Alternatively write your own GUI Library, you can use the PSF2 text drawing routine from my example for that.

Cheers,
bzt
SiliconOS
Posts: 17
Joined: Sun Feb 14, 2021 12:41 am

Re: I want to build an OS on windows

Post by SiliconOS »

bzt wrote:
SiliconOS wrote:I think this write by ASM and pascal(Because it is a OS GUI Library)
I'm not entirely sure what you're asking. All my links are for Pascal, and a kernel shouldn't be a GUI Library at all. Check out the links I gave you:

- mykernel/pas is a minimal "Hello World" kernel written in Pascal. I've used the FreePascal (fpc) compiler for that (known to work under Windows too, supports both ELF and PE). The example uses PSF2 fonts to draw text on the framebuffer (pixel based graphics mode).

- SimpleGUI is a minimal FreePascal GUI library, written for SDL so should be straightforward to port to framebuffer (just remove SDL_Surface, replace
SDL_Surface.pixels with PDword(@fb),
SDL_Surface.w with bootboot.fb_width,
SDL_Surface.h with bootboot.fb_height, and
SDL_Surface.pitch with bootboot.fb_scanline and you're good to go).

- fpGUI is a fully featured GUI library written in FreePascal, although might be more difficult to port as it has more dependencies. But it has a HOW-TO port doc.

Alternatively write your own GUI Library, you can use the PSF2 text drawing routine from my example for that.

Cheers,
bzt
I want to design a thing like Macintosh Toolbox, called Hyperon Toolbox. It including a set of application programming interfaces for software development on the platform.The Toolbox consists of a number of "managers.", such as HyperDraw and etc. It also have some "kernel" functions, libraries, drivers(such IDE driver, HYFS(The OS's filesystem)), fonts and some resources and useful applications(such as HyperBug).

The Toolbox need writed by Pascal and ASM, but I don't know how to call some functions and use some resources
SiliconOS
Posts: 17
Joined: Sun Feb 14, 2021 12:41 am

Re: I want to build an OS on windows

Post by SiliconOS »

I'm trying use C++ to write the OS
Post Reply