OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:18 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 59 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: Multitasking problem
PostPosted: Tue Aug 02, 2022 5:52 am 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Hello again, i have problem with multiboot, when i am trying to run system with modules on some emulators, grub doesn't provide modules, modules count and address are zero, what is reason?
Modules are provided only when virtual machine have 128MB of ram.
When i enable paging the data of multiboot are sets to zero, why?


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Tue Aug 02, 2022 8:11 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
But the multiboot data is provided before you enable paging. If it disappears after you enable paging then you are overwriting the data, or not mapping the memory region where it is contained properly.


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Tue Aug 02, 2022 12:23 pm 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
iansjack wrote:
But the multiboot data is provided before you enable paging. If it disappears after you enable paging then you are overwriting the data, or not mapping the memory region where it is contained properly.

Maybe i overwrite the data.
I have second problem, if i pass the another file as module the module start field are zero, but if i pass the same module as second module, it's work, why?
And about multiboot the same if i load and enable paging after loading modules.
EDIT: Modules works fine, but kernel end address are incorrect, how i can get the kernel end address? And the problem caused by invalid kernel end address.


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Tue Aug 02, 2022 12:59 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
WinExperements wrote:
how i can get the kernel end address?

Define a symbol at the end of your kernel in your linker script. Use the address of that symbol.


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Tue Aug 02, 2022 3:35 pm 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Octocontrabass wrote:
WinExperements wrote:
how i can get the kernel end address?

Define a symbol at the end of your kernel in your linker script. Use the address of that symbol.

Yeah i add this, but the address in this symbol are incorrect, the value is 10696057704939582.
My linker script:
Code:
ENTRY(_start)
OUTPUT_FORMAT(elf32-i386)
OUTPUT_ARCH(i386:i386)

SECTIONS
{
  . = 0x100000;
  kernel_start = .;
  .text :
  {
    *(.multiboot)
    *(.text*)
    *(.rodata)
  }

  .data  :
  {
    *(.data)
  }

  .bss  :
  {
    *(.bss)
  }
  kernel_end = .;
}

What i do wrong in my linker script and how correctly get kernel end address and size?


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Tue Aug 02, 2022 3:59 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
How are you getting an address that doesn't fit in 32 bits?


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Tue Aug 02, 2022 7:26 pm 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Octocontrabass wrote:
How are you getting an address that doesn't fit in 32 bits?

Problem in my linker script or in how i use this variable? I define it as uint64_t in my kernel source


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Tue Aug 02, 2022 10:34 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
You should define linker symbols in C as
Code:
extern char <name>[];
The value of a symbol from the linker shows up as address of a name in C. If you declare that name as an array, just referencing the name will automatically take its address. If you define it as anything else, you must take the address. What you did was likely to dereference it. Thus showing you that there are indeed some data bytes at the end of your kernel, and what they look like if interpreted as a 64-bit number. But that doesn't help you.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Wed Aug 03, 2022 2:32 pm 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Hello again, i have some problems with vga fonts.
After converting psf to elf, my symbol table seems incorrect, what is reason?
Converted PSF symtab:
Code:
Symbol table '.symtab' contains 5 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 SECTION LOCAL  DEFAULT    1
     2: 00000000     0 NOTYPE  GLOBAL DEFAULT    1 _binary_D__Download_font_
     3: 00008020     0 NOTYPE  GLOBAL DEFAULT    1 _binary_D__Download_font_
     4: 00008020     0 NOTYPE  GLOBAL DEFAULT  ABS _binary_D__Download_font_

How i convert it:
Code:
objcopy -O elf32-i386 -B i386 -I binary font.psf font.o


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Wed Aug 03, 2022 2:53 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
There's nothing wrong with your symbol table. The symbol names are being truncated by readelf.

Try "readelf -s -W" or "objdump -t" and you'll see the correct symbol names.


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Sat Aug 06, 2022 8:22 am 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Hello! How i can translate virtual address to physical knows only the page directory and virtual address?


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Sat Aug 06, 2022 8:37 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
You read the physical address from the page directory. The other way round is more difficult (and is not necessarily a 1 to 1 relationship).


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Sat Aug 06, 2022 12:15 pm 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Hello, i am about translation virtual to physical address, how i can get physical address from page table entry?
And how correctly get page table address from page directory?


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Sat Aug 06, 2022 1:50 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
The upper 20 bits of the physical address are stored in the upper 20 bits of the entry. The lower 12 bits of the physical address are always 0. This applies to both page table and page directory entries.

You can get the physical address from the entry by using bitwise AND to mask the lower 12 bits.


Top
 Profile  
 
 Post subject: Re: Multitasking problem
PostPosted: Sat Aug 06, 2022 4:04 pm 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Octocontrabass wrote:
The upper 20 bits of the physical address are stored in the upper 20 bits of the entry. The lower 12 bits of the physical address are always 0. This applies to both page table and page directory entries.

You can get the physical address from the entry by using bitwise AND to mask the lower 12 bits.

How i can mask 12 bits in C? Can you give example of it?


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 63 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