同时编码一个内核可以进行的stdio使用......? [英] Can stdio be used while coding for a Kernel...?

查看:155
本文介绍了同时编码一个内核可以进行的stdio使用......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要建立一个操作系统,一个非常小的和基本的之一,实际上至少功能,codeD用C

I need to build a OS, a very small and basic one, with actually least functionality, coded in C.

也许,做一些内存管理,并具有至少一个文本编辑器和计算器中的崔操作系统,它只是将是一个如何使一个code,它拥有硬件全面和直接控制实验。

Probably a CUI OS which does some memory management and has at least a text editor and a calculator, its just going to be a experimentation about how to make a code that has full and direct control over your hardware.

不过我会需要一个接口,这将需要像printf的输入/输出功能(安培;参数)和scanf(安培;参数)。现在我的基本问题是,我应该利用现有的标题或去从头开始实际的编码,和为何如此?

Still I'll be requiring an interface, that will need input/output functions like printf(&args), scanf(&args). Now my basic question is should I use existing headers or go for coding actually from scratch, and why so ?

我会比非常感谢更多的你们和帮助。

I'd be more than very thankful to you guys for and help.

推荐答案

首先,你不能对任何东西从的libc 链接...你将有至code一切从头开始。

First, you can't link against anything from libc ... you're going to have to code everything from scratch.

现在已经在微内核我自己,我不会用附带的实际 STDIO 标题的libc 因为他们将有很多额外的信息,这将是您的操作系统无论是无关紧要的,或者会造成由于缺少定义等编译器错误我的将的做,虽然是保持弄得一团糟这些标准函数的函数签名相同的......所以最终你将有一个名为 stdio.h中您的操作系统,但是这将是一个非常精简的头与您需要的基本要求,文件,只有您需要的标准I / O功能,配合正确的标准签名。

Now having worked on a micro-kernel myself, I would not use the actual stdio headers that come with libc since they are going to be cluttered with a lot of extra information that will be either irrelevant for your OS, or will create compiler errors due to missing definitions, etc. What I would do though is keep the function signatures for these standard functions the same ... so in the end you would have a file called stdio.h for your OS, but it would be a very stripped down header file with the basic minimum requirements for your needs, and only having the standard I/O functions you need, with the correct standard signatures.

请在后端,即在 stdio.c 文件,你将不得不指出这些功能自定义控制台驱动程序或一些其它类型性格的带动显示器。要么,你可以只用它们作为包装某些其他内核级的显示打印程序。您也打算要确保,即使你可以使用的#include< stdio.h中> 指令在其他的操作系统code模块来访问这些打印功能,你不反对链接的libc 。这可以通过使用 GCC -ffreestanding 来完成。

Keep in mind on the back-end, i.e., in your stdio.c file, you're going to have to point these functions to a custom console-driver or some other type of character drive for your display. Either that, or you could just use them as wrappers for some other kernel-level display printing routine. You are also going to want to make sure that even though you may use a #include <stdio.h> directive in your other OS code modules to access these printing functions, you do not link against libc. This can be done using gcc -ffreestanding.

这篇关于同时编码一个内核可以进行的stdio使用......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆