loading user programs
loading user programs
Ive recently added system calls to my os and tried to load a program i compiled but it doesn't work. it shows that the program is loaded but the program is supose to print out "ok lol" but all i get is something that looks like a smiley face. im leaving my kernel src and 2 pictures. take a look and tell me what u think
the rar file can be downloaded at www.lpsoft.us
no. (edit: the reason I said this was because you're not even giving us any clues as to the location of the problem. You haven't posted any code snippets, or anything. AJ below obviously has more time on his hands than I have!)
Last edited by JamesM on Mon Jul 30, 2007 4:03 am, edited 1 time in total.
Hi,
I have had a bit of a look at the source and unfortunately do not have the time to wade through it all at the moment (some of it looks interesting - I'd like to read it eventually).
I assume that syscall_write is responsible for actually writing to the video device (or have I got this completely wrong?). If you are passing the string to this call in a particular register, I wonder if the wrong register is getting passed to your print function?
Could you summarise what happens on the system call (from the userland and kernel perspectives) and give any relevant code snippets. That way, you are likely to get more of a response from people with less time on their hands!
Cheers,
Adam
I have had a bit of a look at the source and unfortunately do not have the time to wade through it all at the moment (some of it looks interesting - I'd like to read it eventually).
I assume that syscall_write is responsible for actually writing to the video device (or have I got this completely wrong?). If you are passing the string to this call in a particular register, I wonder if the wrong register is getting passed to your print function?
Could you summarise what happens on the system call (from the userland and kernel perspectives) and give any relevant code snippets. That way, you are likely to get more of a response from people with less time on their hands!
Cheers,
Adam
yea i know ppl can be idoits. when i use the system call printf in the kernel it prints normaly, but when i load init.bin and it call the printf function some symbols show up. i dont know if im compiling the user app wrong or if something else is wrong. and im sorry for not adding code snippets its just too much code to put in the forums, thats why i gave my website ![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
What binary file format are you using (ELF, flat)?
Edit: I'm asking because relocation is different across different file formats. A flat binary is next to impossible to relocate (you'd need opcode tables). ELF is designed to be relocated, but you need paging to properly locate it.
Edit 2: I know, because at the moment the programs I'm writing in my OS are the user software for my OS (loaded from the disk).
Edit: I'm asking because relocation is different across different file formats. A flat binary is next to impossible to relocate (you'd need opcode tables). ELF is designed to be relocated, but you need paging to properly locate it.
Edit 2: I know, because at the moment the programs I'm writing in my OS are the user software for my OS (loaded from the disk).
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Try loading the flat binary to a specific location (such as 0x40000) and put an 'org' keyword at the start of it. For the time being it'll suffice.
If it's C make sure that it's linked to run at whatever location you choose.
The reason why you do this is to tell it the offset where memory accesses go to (for instance, in the file a string may be at offset 0x30, but if loaded to 0x40000 it'll still try to access 0x30, so it must be relocated to 0x40030).
I'd get virtual memory and paging working and then work with either COFF or ELF. They're designed to work in a virtual memory space, and the effort required to get paging working is worth the time you save in loading the programs (With paging enabled, loading an ELF executable takes about 20 lines of code).
If it's C make sure that it's linked to run at whatever location you choose.
The reason why you do this is to tell it the offset where memory accesses go to (for instance, in the file a string may be at offset 0x30, but if loaded to 0x40000 it'll still try to access 0x30, so it must be relocated to 0x40030).
I'd get virtual memory and paging working and then work with either COFF or ELF. They're designed to work in a virtual memory space, and the effort required to get paging working is worth the time you save in loading the programs (With paging enabled, loading an ELF executable takes about 20 lines of code).