Like Tree5Likes

Page fault despite doing as tutorial says?

This is a discussion on Page fault despite doing as tutorial says? within the C Programming forums, part of the General Programming Boards category; I had a looky at the source code from the website, and he does provide definitions of these functions (strcat, ...

  1. #16
    Registered User
    Join Date
    Mar 2010
    Posts
    535
    I had a looky at the source code from the website, and he does provide definitions of these functions (strcat, memset etc) in common.c. However in early stages of the tutorial they are just stubs -- have you implemented them? If you don't want to it looks like the "multitasking" version of the sources has implementations.

    Not sure if the implicit declarations could be causing a page fault, possibly. If you're calling something with the wrong arguments the compiler will just let you get away with it if there's no declaration. You should probably put the declarations in a header file, maybe use common.h.

    Eek, just saw this too:
    Code:
    source/common.c: In function ‘strcat’:
    source/common.c:80:22: warning: operation on ‘dest’ may be undefined
    That'd be
    Code:
    *dest = *dest++;
    This is undefined behaviour:
    Question 3.8

    That's the kind of thing that could well have changed between compiler versions (I see this website was written in 2008, so maybe this did what he wanted then). Looks like it should just be
    Code:
    *dest++;
    Last edited by smokeyangel; 04-20-2012 at 08:23 PM.

  2. #17
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    Jimix is a hobby operating system, designed for the x86 and possibly x86-64/ia64 architectures.
    Note the underlined word.

    with
    > Oh, by the way I'm using 64-bit linux with the same gcc compiler as he did/does
    and
    > I'm new to C

    This is far from an ideal combination to be trying out something as fiddly as getting an OS to boot.

    Also, when you have issues with package "foo", the best place to start looking is the "foo" website. Does it have a forum? Does it have an mailing list? Can you email the author?
    These are the support channels you need to explore first.

    Anyway, how about starting with a simple main() that just displays "success" and then halts.
    Unless Molloy has already fixed the asm code to correctly initialise a 64-bit environment, it isn't even getting anywhere near main.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #18
    Registered User
    Join Date
    May 2009
    Posts
    2,553
    I would like to do something like this in the future; but, not likely to have the time for more than a year.

    Links: I stumbled across looking for better example code.

    Note: The work of Herbert Bos only does the first 3 steps of James Molloy; so, not likely to solve the this thread problem.
    But, the code looks like well written C code; but, I have not tried to compile it.
    http://www.cs.vu.nl/~herbertb/misc/basickernel.pdf
    http://www.cs.vu.nl/~herbertb/misc/writingkernels.txt
    http://www.cs.vu.nl/~herbertb/misc/w...helloworld.tgz

    The work of James Molloy and Herbert Bos were both based on Bran's work.
    Bran's Kernel Development Tutorial on Bona Fide OS Developer
    Looks like same info; but it is more readable in Firefox web browser.
    http://www.osdever.net/bkerndev/Docs/title.htm

    I suggest looking at the Tutorials here
    Tutorials - OSDev Wiki

    Tim S.
    Last edited by stahta01; 04-21-2012 at 08:06 AM.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  4. #19
    Registered User
    Join Date
    Apr 2012
    Location
    Cwmbran, South Wales
    Posts
    16
    Thanks for the links guys, most of them I have already had a look through XD. I have gotten rid of almost all the implicit declarations ( except copy_page_physical as it is in the asm file ). But there are still some I can't shake, so I'll update the OP with the new errors.

  5. #20
    Registered User
    Join Date
    Apr 2012
    Location
    Cwmbran, South Wales
    Posts
    16
    I guess I can't update it so I'll post them here ( hopefully it'll work ):

    Code:
    source/main.c: In function ‘main’:
    source/main.c:81:4: warning: pointer targets in passing argument 4 of ‘read_fs’ differ in signedness
    headers/fs.h:58:8: note: expected ‘u8int *’ but argument is of type ‘char *’
    source/common.c: In function ‘strcat’:
    source/common.c:81:22: warning: operation on ‘dest’ may be undefined
    source/common.c: In function ‘panic’:
    source/common.c:106:5: warning: passing argument 1 of ‘monitor_write’ discards qualifiers from pointer target type
    headers/monitor.h:16:6: note: expected ‘char *’ but argument is of type ‘const char *’
    source/common.c:108:5: warning: passing argument 1 of ‘monitor_write’ discards qualifiers from pointer target type
    headers/monitor.h:16:6: note: expected ‘char *’ but argument is of type ‘const char *’
    source/common.c: In function ‘panic_assert’:
    source/common.c:122:5: warning: passing argument 1 of ‘monitor_write’ discards qualifiers from pointer target type
    headers/monitor.h:16:6: note: expected ‘char *’ but argument is of type ‘const char *’
    source/common.c:124:5: warning: passing argument 1 of ‘monitor_write’ discards qualifiers from pointer target type
    headers/monitor.h:16:6: note: expected ‘char *’ but argument is of type ‘const char *’
    source/common.c: In function ‘strcpy’:
    source/common.c:73:1: warning: control reaches end of non-void function
    source/descriptor_tables.c: In function ‘init_descriptor_tables’:
    source/descriptor_tables.c:42:5: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘void (* (*)[])(struct registers_t *)’
    source/descriptor_tables.c: In function ‘write_tss’:
    source/descriptor_tables.c:86:5: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘struct tss_entry_t *’
    source/descriptor_tables.c: In function ‘init_idt’:
    source/descriptor_tables.c:111:5: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘struct idt_entry_t (*)[256]’
    source/kheap.c: In function ‘expand’:
    source/kheap.c:76:5: warning: suggest parentheses around comparison in operand of ‘&’
    source/kheap.c: In function ‘find_smallest_hole’:
    source/kheap.c:139:13: warning: suggest parentheses around comparison in operand of ‘&’
    source/kheap.c: In function ‘create_heap’:
    source/kheap.c:177:5: warning: suggest parentheses around comparison in operand of ‘&’
    source/paging.c: In function ‘initialise_paging’:
    source/paging.c:119:5: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘u32int *’
    source/paging.c:124:5: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘struct page_directory_t *’
    source/paging.c:122:12: warning: unused variable ‘phys’
    source/paging.c: In function ‘get_page’:
    source/paging.c:195:9: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘struct page_table_t *’
    source/paging.c: In function ‘page_fault’:
    source/paging.c:218:9: warning: unused variable ‘id’
    source/paging.c: In function ‘clone_table’:
    source/paging.c:240:5: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘struct page_table_t *’
    source/paging.c:258:2: warning: implicit declaration of function ‘copy_page_physical’
    source/paging.c: In function ‘clone_directory’:
    source/paging.c:269:5: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘struct page_directory_t *’
    source/paging.c: At top level:
    source/paging.c:45:15: warning: ‘test_frame’ defined but not used
    source/paging.c: In function ‘first_frame’:
    source/paging.c:72:1: warning: control reaches end of non-void function
    source/ordered_array.c: In function ‘create_ordered_array’:
    source/ordered_array.c:17:5: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘void **’
    source/ordered_array.c: In function ‘place_ordered_array’:
    source/ordered_array.c:28:5: warning: passing argument 1 of ‘memset’ from incompatible pointer type
    headers/common.h:21:6: note: expected ‘u8int *’ but argument is of type ‘void **’
    source/initrd.c: In function ‘initialise_initrd’:
    source/initrd.c:105:9: warning: passing argument 2 of ‘strcpy’ from incompatible pointer type
    headers/common.h:23:6: note: expected ‘const char *’ but argument is of type ‘s8int (*)[64]’
    I just can't shake the errors XD any files you need just say and I'll post 'em

  6. #21
    Registered User
    Join Date
    May 2009
    Posts
    2,553
    Updated source is supposed to be here somewhere jamesm-tutorials - JamesM's kernel development tutorials - Google Project Hosting

    The code you using has KNOWN bugs in it.

    Per thread: OSDev.org • View topic - Are JamesM's tutorials still being maintained?

    I strongly recommend using the right forum for OS Dev for your next question on this topic.http://forum.osdev.org

    Tim S.
    Last edited by stahta01; 04-21-2012 at 08:39 AM.
    Salem and Jamie_Edwards like this.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  7. #22
    Registered User
    Join Date
    Apr 2012
    Location
    Cwmbran, South Wales
    Posts
    16
    Quote Originally Posted by stahta01 View Post
    Updated source is supposed to be here somewhere jamesm-tutorials - JamesM's kernel development tutorials - Google Project Hosting

    The code you using has KNOWN bugs in it.

    Per thread: OSDev.org • View topic - Are JamesM's tutorials still being maintained?

    I strongly recommend using the right forum for OS Dev for your next question on this topic.OSDev.org • Index page

    Tim S.
    Thanks for finding that! Shame he isn't maintaining the original tutorial though. I shouldn't have much of a problem with the code now XD

    Once again thanks.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Re: Explorer Page Fault error.
    By Adock in forum Tech Board
    Replies: 2
    Last Post: 07-25-2009, 02:39 AM
  2. Explorer Error Page fault
    By Adock in forum Tech Board
    Replies: 12
    Last Post: 07-24-2009, 04:24 PM
  3. monitor page fault
    By George2 in forum Tech Board
    Replies: 0
    Last Post: 01-15-2008, 03:17 AM
  4. page fault
    By George2 in forum C++ Programming
    Replies: 9
    Last Post: 01-10-2008, 05:27 AM
  5. Page Fault in Visual C++
    By readerwhiz in forum C Programming
    Replies: 6
    Last Post: 05-03-2002, 12:30 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21