OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Sep 23, 2020 7:26 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: OS cannot display text
PostPosted: Mon Nov 25, 2019 1:12 pm 
Offline

Joined: Mon Nov 25, 2019 1:05 pm
Posts: 6
Hi everyone, I'm Italian and I'm experimenting with creating my operating system. For now it has only a VGA driver and keyboard support (without interrupts). I followed the tutorial "Meaty Skeleton" of the wiki and my OS has a problem: from QEMU everything works, while from real hardware (Intel Pentium Gold CPU) after the GRUB menu I get: "warning: no console available for OS"
"error: no suitable video mode found." and from there if I press ESC it restarts (I think because I implemented that with the ESC key it should turn off, but it restarts). Perhaps because the OS is 32 bit while the PC is 64 bit? I'm using the cross-compiler built on Ubuntu 19.10 i686-elf-gcc. Thanks to all in advance.
P.S. I apologize for my English, but I used the Google translator.


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Mon Nov 25, 2019 5:50 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1641
Location: Athens, GA, USA
maurotram wrote:
Hi everyone, I'm Italian and I'm experimenting with creating my operating system.

As a new member, I would like to point you to this pinned thread and the various wiki pages it links to, if you haven't done so already. Given what you say below, I am assuming you've read that already, but I feel that I need to follow up with my due diligence on this matter.

maurotram wrote:
For now it has only a VGA driver and keyboard support (without interrupts). I followed the tutorial "Meaty Skeleton" of the wiki and my OS has a problem: from QEMU everything works, while from real hardware (Intel Pentium Gold CPU) after the GRUB menu I get: "warning: no console available for OS"
"error: no suitable video mode found." and from there if I press ESC it restarts (I think because I implemented that with the ESC key it should turn off, but it restarts).

OK, could you provide us with the following, please?
  • The QEMU command line you use when testing in the VM, with specific note of the video settings.
  • The specific details of the live hardware, such as CPU model (G[4|5]xx0 for desktop Pentium Golds, [4|5]xx0Y for mobile, G[4|5]xx0T for low-power systems), available RAM, and motherboard brand and model (or the brand and model of the laptop or SBC, as appropriate).
  • Your OS source code, especially any parts where you modified it from the original Meaty Skeleton recommendations (which, as a practical matter, you almost would have had to, as it is not as much of a 'do x, y, and z' like Bare Bones, and more of a 'here are some of the things you can try' sort of tutorial).
  • Your GRUB boot configuration settings
  • Your Makefile and linker script
  • the VGA mode you are trying to enable (both the mode number and the resolution, if you have them)

Chances are, some of those aren't going to be strictly necessary to solve the problem, but it's hard to say which will be relevant until we've seen them all. If you have an offsite repo - and I will repeat my advice to set one up if you don't, as often as I can - then wel can view the source code, Makefile, and linker script there.

The fact that it runs under QEMU but not live hardware, and the specific error messages GRUB returns, makes me think that you are setting it to a non-text video mode, but then trying to write to the text buffer. Conversely, it could be that the current build is dependent on a specific video mode which is either unique to the emulator (e.g., the 'generic' VGA mode, the Cirrus Logic mode, or something else which reflects an abstracted and/or outdated video model), or an older video mode which is no longer supported by all GPUs or video subsystems.

maurotram wrote:
Perhaps because the OS is 32 bit while the PC is 64 bit?


Hmmn, that may depend on the GRUB configuration, and perhaps the specific motherboard and UEFI implementation, but in general, no, it shouldn't matter. My understanding is that unless the UEFI launcher is 64-bit-only (I don't know of any for x86 which are, not yet anyway, but I have heard that some might be), GRUB amways runs in 32-bit protected mode, and is in that mode when it hands control over to the OS regardless of anything else. I am not even sure if there's an option to switch to long mode before the hand-off, off-hand.

Comments and corrections welcome.

maurotram wrote:
I'm using the cross-compiler built on Ubuntu 19.10 i686-elf-gcc. Thanks to all in advance.

The cross-compiler is set to target i686-elf-gcc, I presume? If you could, please run your cross-compiler with the -dumpmachine flag (as described on the wiki page Target Triplet) and post the results.

maurotram wrote:
P.S. I apologize for my English, but I used the Google translator.

If so, then I would say that Google has greatly improved their translation system. Interesting.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
μή εἶναι βασιλικήν ἀτραπόν ἐπί γεωμετρίαν
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Mon Nov 25, 2019 9:46 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2004 11:00 pm
Posts: 868
Location: WA
Schol-R-LEA wrote:
The fact that it runs under QEMU but not live hardware, and the specific error messages GRUB returns, makes me think that you are setting it to a non-text video mode, but then trying to write to the text buffer.

actually, my first thought was exactly the opposite

GRUB will neither know, nor care, if you try to write to the text buffer

however, if you don't request a graphics mode then GRUB might give an error similar to
Quote:
"warning: no console available for OS"
"error: no suitable video mode found."

because by default it assumes you want text mode (or "console" mode, thus "no console available") and it cannot find a mode similar to the requested mode (text mode, thus "no suitable video mode found") because UEFI is incapable of text mode (and I don't believe there is any such thing as a "Pentium Gold" system which supports CSM)

_________________
## ---- ----- ------ Intel Manuals
OSdev wiki


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Tue Nov 26, 2019 7:23 am 
Offline

Joined: Mon Nov 25, 2019 1:05 pm
Posts: 6
First of all, thanks for the answers. Start with the i686-elf-gcc -dumpmachine command:
Code:
mauro @ mauro-pc: ~ $ i686-elf-gcc -dumpmachine
i686-elf


File grub.cfg:
Code:
menuentry "MaurOS" {
multiboot /boot/mauros.kernel
timeout = 0
boot
}

For QEMU I use the script provided by Meaty Skeleton:
Code:
#! /bin/sh
set -e
. ./iso.sh

qemu-system - $ (./ target-triplet-to-arch.sh $ HOST) -cdrom mauros.iso

The PC is an HP Pavilion x360, 8GB of RAM and Intel Pentium Gold 4415U CPU (1 CPU, 2 cores, 4 threads) 2.30 GHz.
As Makefile and linker I use those provided by Meaty Skeleton.
At the source of the OS I added only the functions outb and inb, update cursor, enable_cursor, disable_cursor as indicated in the wiki and the function putok () which prints an [OK] similar to the loading of the various Linux modules. I also added keyboard support, for now only numbers from 1 to 9, and the Enter and Esc keys, to wrap and reboot (it would turn off but ...) and the delete key. Keyboard code:
Code:
int keyboard_event () {
int i, scancode;
for (i = 10000; i> 0; i ++) {
        // Check if scan code is ready
        if ((inb (0x64) & 1) == 0) continue;
        // Get the scan code
        scancode = inb (0x60);
        break;
    }
return scancode;


}

and then a switch-case for each hexadecimal code.
Ah, I have another problem, and I take this opportunity to tell you about it here if it is granted otherwise I will open another thread. I tried to add the inb and outb functions as prototypes in stdio.h, then I created the 2 files outb.ce inb.c in libc / stdio and including stdio.h I thought they would link (I also included them in the Makefile in FREEOBJS) but if I try to call them from the kernel it doesn't find them and I also get a warning:
Code:
Warning: "outb" function declared static but never defined
"
and then an
Code:
Error: undefined reference to" outb "
. It s what for inb, so I have them completely defined in stdio.h without writing only the prototypes.The VGA driver I mentioned earlier is actually the same already written in Meaty Skeleton (tty.c) adding only the support for \n and \b and at the cursor. be useful, given the output of lscpu:
Code:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   39 bits physical, 48 bits virtual
CPU(s):                          4
On-line CPU(s) list:             0-3
Thread(s) per core:              2
Core(s) per socket:              2
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           142
Model name:                      Intel(R) Pentium(R) CPU 4415U @ 2.30GHz
Stepping:                        9
CPU MHz:                         800.007
CPU max MHz:                     2300,0000
CPU min MHz:                     400,0000
BogoMIPS:                        4599.93
Virtualization:                  VT-x
L1d cache:                       64 KiB
L1i cache:                       64 KiB
L2 cache:                        512 KiB
L3 cache:                        2 MiB
NUMA node0 CPU(s):               0-3
Vulnerability Itlb multihit:     KVM: Mitigation: Split huge pages
Vulnerability L1tf:              Mitigation; PTE Inversion; VMX conditional cach
                                 e flushes, SMT vulnerable
Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:          Mitigation; PTI
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled v
                                 ia prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user
                                  pointer sanitization
Vulnerability Spectre v2:        Mitigation; Full generic retpoline, IBPB condit
                                 ional, IBRS_FW, STIBP conditional, RSB filling
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtr
                                 r pge mca cmov pat pse36 clflush dts acpi mmx f
                                 xsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rd
                                 tscp lm constant_tsc art arch_perfmon pebs bts
                                 rep_good nopl xtopology nonstop_tsc cpuid aperf
                                 mperf pni pclmulqdq dtes64 monitor ds_cpl vmx e
                                 st tm2 ssse3 sdbg cx16 xtpr pdcm pcid sse4_1 ss
                                 e4_2 x2apic movbe popcnt tsc_deadline_timer aes
                                  xsave rdrand lahf_lm abm 3dnowprefetch cpuid_f
                                 ault epb invpcid_single pti ssbd ibrs ibpb stib
                                 p tpr_shadow vnmi flexpriority ept vpid ept_ad
                                 fsgsbase tsc_adjust smep erms invpcid mpx rdsee
                                 d smap clflushopt intel_pt xsaveopt xsavec xget
                                 bv1 xsaves dtherm arat pln pts hwp hwp_notify h
                                 wp_act_window hwp_epp md_clear flush_l1d

EDIT: At startup of QEMU i get this message: "Guest has not initialized the display (yet)" and then all works.

_________________
MaurOS alpha - Website (ITA) - GitHub


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Tue Nov 26, 2019 9:38 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1641
Location: Athens, GA, USA
JAAman wrote:
Schol-R-LEA wrote:
The fact that it runs under QEMU but not live hardware, and the specific error messages GRUB returns, makes me think that you are setting it to a non-text video mode, but then trying to write to the text buffer.

actually, my first thought was exactly the opposite [...]


Ugh, that was a brainfart on my part. Thank you for pointing out that, I feel a bit foolish now; I knew that GRUB shouldn't care about writing to the text buffer, but for some reason, I couldn't think through an alternative. This makes much more sense.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
μή εἶναι βασιλικήν ἀτραπόν ἐπί γεωμετρίαν
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Tue Nov 26, 2019 10:58 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2004 11:00 pm
Posts: 868
Location: WA
Quote:
The PC is an HP Pavilion x360, 8GB of RAM and Intel Pentium Gold 4415U CPU (1 CPU, 2 cores, 4 threads) 2.30 GHz.

unfortunately, that meaty skeleton tutorial is designed for computers from the 1980s, and will not work on anything but emulators today -- that computer is far too modern for the meaty skeleton tutorial to work on it

the meaty skeleton tutorial (and all the barebones ones too) should probably be removed from the wiki (or at least moved to an "old deprecated information" subsection)
Quote:
At the source of the OS I added only the functions outb and inb, update cursor, enable_cursor, disable_cursor as indicated in the wiki

the inb and outb functions themselves probably work fine, but what you are using them with probably won't
the update cursor, enable cursor, and disable cursor functions definitely will not work on real hardware (they are emulator-only functions)
Quote:
I also added keyboard support, for now only numbers from 1 to 9, and the Enter and Esc keys
to wrap and reboot (it would turn off but ...) and the delete key. Keyboard code:
Code:
int keyboard_event () {
int i, scancode;
for (i = 10000; i> 0; i ++) {
        // Check if scan code is ready
        if ((inb (0x64) & 1) == 0) continue;
        // Get the scan code
        scancode = inb (0x60);
        break;
    }
return scancode;


}


that keyboard code will not work on many, perhaps even most, modern computers -- whether or not it will work on your specific machine you would have to test and see
Quote:
The VGA driver I mentioned earlier is actually the same already written in Meaty Skeleton (tty.c) adding only the support for \n and \b and at the cursor.

we generally don't refer to that as a "VGA driver" (that term usually refers to something else)

unfortunately, this is where the problem is, and why your code won't boot
the meaty skeleton tutorial relies on text mode, which is standard on computers from the 1980s and emulators, but on modern computers (especially computers built since 2012) there is no text mode

since you expect to use text mode, you didn't tell GRUB to load you into a graphics mode, but GRUB cannot provide text mode, and it knows that your code won't work correctly without text mode, so it refuses to run your code and gives an error

the only way to fix this error is to ask GRUB to set a graphics mode... but unfortunately, that means you will not be able to print text on the screen using the code you have

instead you will need to "draw" the text onto the screen -- really printing in graphics mode with a simple bitmapped font isn't too hard, but it isn't in the tutorial because the tutorial is written for extremely old computers and emulators


really, the proper way to fix this is to start over, this time using the UEFI_Bare_Bones tutorial (and not GRUB) and the information from the UEFI page

using UEFI, your code should work on all computers since 2012, most computers since 2007, and almost all emulators but will not work on most computers older than 2007

_________________
## ---- ----- ------ Intel Manuals
OSdev wiki


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Tue Nov 26, 2019 11:51 am 
Offline

Joined: Mon Nov 25, 2019 1:05 pm
Posts: 6
Ok, so all the tutorials on osdev except for UEFI bare bones are obsolete and I have to look for some other tutorials?

_________________
MaurOS alpha - Website (ITA) - GitHub


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Tue Nov 26, 2019 3:34 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2004 11:00 pm
Posts: 868
Location: WA
I haven't seen many tutorials other than our one at UEFI_Bare_Bones, unfortunately (there are hundreds of tutorials for the old system) -- though admittedly I haven't really been looking

I really think the UEFI Bare Bones article needs to be rewritten (both simplified for new users and extended to cover more material) and made the first starter page on the wiki -- the first place all new OSdevers begin (it should be the first and only place to direct all new members) -- and while doing that, mark all the old tutorials and information as deprecated, hidden from casual browsers and newcomers


you really have 3 choices:
1) limit yourself to emulators and very old computers and continue using the information you already have
in this case, what you have is a good start, you just continue building on that, it will work on most emulators and all very old computers


2) use GRUB as you are doing now, but don't rely on any of the older technologies
if you want to keep what you have now, all you really need to do is tell GRUB to give you a graphics mode (its an option in the multiboot header), then your code should load on real hardware, however it won't print anything on the screen (either on real hardware or on QEMU either, since you will be using the same graphics mode on both)

to print to the screen you will need to create a font and paint it to the screen -- rendering a simple bitmap font is not hard, but it is beyond the scope of this post

your keyboard code may or may not work (it will probably work in QEMU, unless you change how QEMU is configured) if it does work then that is great (because USB is not an easy beginner project)


3) use the new system (which means changing how you do things)
this would require starting over, getting some new tools, and learning to interact with the firmware, however it does have advantages, since UEFI will provide functions for almost everything you might want in the early stages (including printing to the screen, keyboard input, graphics mode setup, file loading, etc)
however this won't work on really old computers and emulators might need to be customized to run it

after completing what the tutorial covers (which isn't much), some additional steps to consider:
-print any diagnostics messages using the firmware print functions
-setup a graphics mode (select a graphics mode for your OS to use, and obtain all the information about it)
-load any additional files you might want to load with the firmware's assistance
-obtain the memory map and call exit boot services (these must be done at the same time)
-print to the screen in graphics mode (this will require rendering a simple font to the screen)
-properly correct the memory map (remove duplicate entries, resolve conflicting entries, reorder entries, combine entries, align entries, etc.)
-initialize paging/physical memory manager/virtual memory manager/kernel memory manager

_________________
## ---- ----- ------ Intel Manuals
OSdev wiki


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Wed Nov 27, 2019 9:33 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1641
Location: Athens, GA, USA
@JAAman: You should be able to make changes to the wiki yourself, though given the scope of the request, I would recommend discussing it with others in greater detail first. I've created a thread for this in the OSDev Wiki subforum to discuss the matter further.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
μή εἶναι βασιλικήν ἀτραπόν ἐπί γεωμετρίαν
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Wed Nov 27, 2019 10:42 am 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 279
Location: Private, UK
JAAman wrote:
on modern computers (especially computers built since 2012) there is no text mode


That's not really true. On a minority of very recent systems, mostly "ultraportable"/"tablet" systems and systems and a very few desktops and "conventional" laptops, there is no BIOS with support for "text mode".

If it can boot Windows 7, it has video BIOS ("int 10h") support almost certainly including "text mode" (Microsoft's support pages confirm this requirement). Most "conventional" laptops/desktops on sale today can still boot Windows 7.

Since "text mode" is a hardware feature and is not dependent on firmware and since virtually all (if not actually all) graphics cards on sale today still support Windows 7 in some capacity, they still almost definitely have a "text mode". While VGA register compatibility is not specifically required by Windows 7, it's still highly likely to be present. With "integrated" graphics, such legacy compatibility features may not be present, but this is more likely to affect portables.

Since MS-DOS can still run natively (whatever that means for x86...) on AMD's latest "Ryzen" processors (example) and that absolutely requires "text mode", the "death" of text mode is a little exaggerated.

Personally, I'm targeting my OS at older generation hardware anyway...

_________________
Image


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Sat Nov 30, 2019 11:55 am 
Offline

Joined: Mon Nov 25, 2019 1:05 pm
Posts: 6
I have an old pc (2007). Can I try on it?

_________________
MaurOS alpha - Website (ITA) - GitHub


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Sat Nov 30, 2019 12:58 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1641
Location: Athens, GA, USA
maurotram wrote:
I have an old pc (2007). Can I try on it?


Possibly, if you have the same version of GRUB installed on that one as well, but since it is almost certain to be a Legacy BIOS system rather than a UEFI system, you may need a slightly different GRUB configuration. There's no way to know for certain until you try, I guess.

One caveat I will make is that if the newer machine is using GRUB 2 (which follows the Multiboot 2.x specification) and the older machine still has GRUB 0.99 installed on it (also called GRUB Legacy, which was based on the Multiboot 1.x spec), then you'd need to either upgrade the GRUB installation on the older system, or rework you Multiboot header to work with the older standard.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
μή εἶναι βασιλικήν ἀτραπόν ἐπί γεωμετρίαν
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: OS cannot display text
PostPosted: Wed Dec 04, 2019 9:20 am 
Offline

Joined: Mon Nov 25, 2019 1:05 pm
Posts: 6
I tried it on the old computer and it works! Also the cursor, the colors and the keyboard.

_________________
MaurOS alpha - Website (ITA) - GitHub


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: bloodline and 9 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