Page 1 of 2
I want to build an OS on windows
Posted: Wed Mar 24, 2021 3:39 am
by SiliconOS
The reason is Windows cannot compile source code to elf.
I try mingw, cygwin and etc.
But they cannot compile to elf!
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 4:02 am
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.
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 4:06 am
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.
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 5:10 am
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
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 6:38 am
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)
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 7:36 am
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
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 7:37 am
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.
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 8:19 am
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.
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 9:09 am
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
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 9:47 am
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
Re: I want to build an OS on windows
Posted: Wed Mar 24, 2021 10:31 pm
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
Re: I want to build an OS on windows
Posted: Thu Mar 25, 2021 2:50 am
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)
Re: I want to build an OS on windows
Posted: Thu Mar 25, 2021 5:49 am
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
Re: I want to build an OS on windows
Posted: Thu Mar 25, 2021 7:11 am
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
Re: I want to build an OS on windows
Posted: Fri Mar 26, 2021 1:15 am
by SiliconOS
I'm trying use C++ to write the OS