Getting Started: Difference between revisions

m
Reverted edits by Melina148 (talk) to last revision by Heat
[unchecked revision][unchecked revision]
m (Reverted edits by Melina148 (talk) to last revision by Heat)
 
(10 intermediate revisions by 7 users not shown)
Line 42:
 
==Choosing your development environment==
You need a platform to develop your new system on. Following the trends of general computing, the two most popular are Windows andis GNU/Linux, but many use Windows too. Developers using a GNU/Linux system have a slight advantage in availability of tools, but this can be solved on Windows using a system such as [[Cygwin]] or [[MinGW]].
 
* '''Binutils''': Fundamental tools for manipulation of object files.
Line 54:
 
You might not use all of these tools, but it is best to have them on hand "just in case," and know how to use them, even at a basic level. But if you decided to use another [[Languages | language]] then the tooling is mostly up to you and maybe the list above just won't help you in any way. Below is the information mostly related to the C/C++ or Assembly developers.
 
===GNU/Linux===
 
The most recommended system for OS development is GNU/Linux. When using GNU/Linux, most of the GNU development tools are probably already present. If not, use your distribution's package management tools (APT, RPM, Portage, Pacman, Apk, etc.) to install them as needed. Again, making a [[GCC Cross-Compiler | cross-compiler]] is required, so as not to link in the development system's runtime files.
 
Common editors are [[Wikipedia:Vim (text editor)|Vim]], [[Wikipedia:Emacs|Emacs]], [[Wikipedia:KDevelop|KDevelop]], [[Wikipedia:Komodo_Edit|Komodo Edit]], etc. Some prefer lightweight editors instead of an IDE, such as [[Wikipedia:gedit|gedit]], [[Wikipedia:Geany|Geany]] and [[Wikipedia:SciTE|SciTE]]. Many like [[Wikipedia:Midnight_Commander|Midnight Commander]] which has a [[Text UI]] and a built-in editor (mcedit) and therefore extremely lightweight and lightning fast.
 
About which distributions you should use, consult the [https://en.wikipedia.org/wiki/List_of_Linux_distributions list of Linux distributions]. They come in all shapes and sizes, but as long as they're relatively general-purpose, they should be fine.
 
If you are unsure, try Ubuntu, Fedora or Linux Mint.
 
===Windows===
 
In order to get the tools necessary, you should install the [[Cygwin]] environment. [[MinGW]] or [[DJGPP]] are alternatives, but Cygwin[https://www.msys2.org/ MSYS2] is strongly suggested as it is the most complete and compatible environment, and also includes a package manager to install libraries and tools.
 
Microsoft has recently (as of writing) released the Windows Subsystem for Linux as an optional feature for Windows 10. It is basically a real Ubuntu command line distribution running on top of Windows WITHOUT the use of a VM. The latest GCC and Binutils (6.1.0 and 2.27 as of writing) compile and work correctly in this environment. Using the Bash shell, you can access your Windows hard disks through /mnt/<drive letter>. The advantage of this solution is that you can work with whichever Windows or Linux tools that you require, without having to find out if they work in Cygwin. Many of the needed tools can be installed using "apt-get".
Line 63 ⟶ 73:
For all of the above, it is strongly suggested to build a cross-compiler, not only because the default compilers target different [[Executable Formats|executable format]]s, but because it's generally a good idea. Check the [[GCC Cross-Compiler]] page for details and instructions.
 
You will also need an editor. Using Notepad will work, but it's easier if you have a more complete editor. For example, [http://notepad-plus-plus.sourceforge.netorg/uk/site.htm Notepad++] or [http://www.flos-freeware.ch/notepad2.html Notepad2] are used by many people. If you are comfortable with Unix editors, you can pick one from the choice Cygwin provides (which includes e.g. Vim and Emacs, which take some getting-used-to but are very powerful).
 
It is also possible to use [[Visual Studio]], or the freely downloadable [http://www.microsoft.com/express/ Visual C++ Express Edition], to write and compile your operating system. You will require a special configuration file, and you will certainly be in the minority, but it does work quite well. You can even install the Windows SDK on top, enabling 64 bit development. The only pitfall is this doesn't support Inline Assembly.
Line 69 ⟶ 79:
Other tools such as [[Watcom]] or [[Borland]] can be used, too, but they each have specific requirements of their own, and are not widely used for this kind of work.
 
Another consideration is that you will probably have as a goal for your OS to be self-hosting, that is, you can compile your operating system using your operating system. If your OS is written in C, your minimal requirements will therefore be a C compiler and C library. If you intend for your OS to be a Windows clone rather than another POSIX-compliant OS, you will need a C library that does Windows calls instead of POSIX calls, and you will need a C compiler that uses just the C library instead of doing POSIX calls. [http://pdos.org GCCWIN + PDPCLIB] fits this bill.
===GNU/Linux===
 
When using GNU/Linux, most of the GNU development tools are probably already present. If not, use your distribution's package management tools (APT, RPM, Portage, Apk, etc) to install them as needed. Again, making a [[GCC Cross-Compiler | cross-compiler]] is required, so as not to link in the development system's runtime files.
===MacOS===
 
Because under the hood it uses FreeBSD's userland, it is fully POSIX compatible. All the usual tools are available (vi, bash, dd, cat, sed, tar, cpio, etc.) Almost every tutorial works out-of-the-box. The missing tools are mostly file system related: no [[Loopback_Device|loopback device]], no fdisk, no mkfs.vfat nor mtools. But you can use diskutil for these purposes, or use [https://brew.sh/ brew] or [https://www.macports.org/ macports] to install those missing tools.
 
To get gcc, you used to have an mpkg on the 2nd Installation DVD for the older versions. Newer MacOS versions (10.13 and up) can install command line XCode (not the IDE, just the toolchain) by running "xcode-select --install" from a Terminal. This will install gcc, binutils and make. This gcc is actually a masquaraded CLang, but featurefull enough to build your own [[GCC_Cross-Compiler|cross-compiler]] without problems. It is preferred to use the official compiler for bootstraping gcc than to install one from brew or macports.
Common editors are [[Wikipedia:Vim (text editor)|Vim]], [[Wikipedia:Emacs|Emacs]], and [[Wikipedia:KDevelop|KDevelop]].
 
===Testing your operating system===
{{Main|Testing}}
The above article goes into a lot of depth about choosing how to test your operating system and how to integrate that with your development process. Both physical and emulated testing environments are discussed.
Line 85 ⟶ 98:
We cannot stress this point strongly enough: if you are not using source control already, you should start doing so immediately. You only need make a serious mistake in your code once to realize the importance of having your code securely versioned and easily retrievable. While it may seem like overkill for a small, private hobby project, once you get into the habit of using revision control, you'll wonder how you ever did without it.
 
For Git you can create your project on [https://github.com/ GitHub]. or [https://bitbucket.org Bitbucket] is also a good alternative as it supports both Git and Mercurial. Both come with free, private repositories.
 
An additional benefit of using version control on a network-accessible repository is that it makes it a lot easier to collaborate with and get help from others. This can be quite useful, especially in the forums, as it can avoid the need for constantly posting updated versions of your code to a message thread--you simply point the conversation towards your repository, and the others in the thread will have direct access to your most current changes. It is also crucial if, as the project grows, you begin to work with other developers on the project (just [[Beginner Mistakes#Teamwork|don't expect that to happen overnight]]).
Line 91 ⟶ 104:
==Common starting points==
 
The easiest way to get a "helloHello worldWorld" 64-bit [[Higher Half Kernel|higher half kernel]] going is the [[Limine Bare Bones]] tutorial. A different approach would be to learn how the computer itself starts up, on the [[Boot Sequence]] page.
 
There are many other [[Tutorials]] available, too.
Anonymous user