OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 1:43 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 3:39 am 
Offline

Joined: Sun Feb 14, 2021 12:41 am
Posts: 17
The reason is Windows cannot compile source code to elf.
I try mingw, cygwin and etc.
But they cannot compile to elf!


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 4:02 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
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.


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 4:06 am 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2292
Location: USA (and Australia)
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.


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 5:10 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 6:38 am 
Offline

Joined: Sun Feb 14, 2021 12:41 am
Posts: 17
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)


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 7:36 am 
Offline

Joined: Sun Feb 14, 2021 12:41 am
Posts: 17
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


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 7:37 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3180
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.


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 8:19 am 
Offline

Joined: Sun Feb 14, 2021 12:41 am
Posts: 17
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.


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 9:09 am 
Offline
Member
Member

Joined: Tue Aug 11, 2020 12:14 pm
Posts: 151
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:
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


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 9:47 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Wed Mar 24, 2021 10:31 pm 
Offline

Joined: Sun Feb 14, 2021 12:41 am
Posts: 17
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:
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


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Thu Mar 25, 2021 2:50 am 
Offline

Joined: Sun Feb 14, 2021 12:41 am
Posts: 17
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)


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Thu Mar 25, 2021 5:49 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Thu Mar 25, 2021 7:11 am 
Offline

Joined: Sun Feb 14, 2021 12:41 am
Posts: 17
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


Top
 Profile  
 
 Post subject: Re: I want to build an OS on windows
PostPosted: Fri Mar 26, 2021 1:15 am 
Offline

Joined: Sun Feb 14, 2021 12:41 am
Posts: 17
I'm trying use C++ to write the OS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: songziming and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group