Thread: shut down the system

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    1

    shut down the system

    i used the following statement to reboot the system.
    reboot(0x4321fedc);
    can any one give an idea , what is happing internally.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Read the manual?
    Look at the source code?
    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.

  3. #3
    Registered Luser risby's Avatar
    Join Date
    Jun 2006
    Posts
    72
    Quote Originally Posted by rama chandra
    i used the following statement to reboot the system.
    reboot(0x4321fedc);
    can any one give an idea , what is happing internally.
    The cpu can put data on the data bus to transfer to memory or the i/o bus to transfer to other chips. When it comes across the machine code to reboot it will send an appropriate value via the i/o bus to chips controlling external devices and to it's own reset pin. To find out more about how your particular processor handles reset you need to find a document like this one which is for the Intel Pentium 4 chip.

    If you mean what is the parameter used for then, on my Suse Linux system, the command:
    Code:
    man 2 reboot
    describes several alternative parameter values allowing you to vary the outcome by restarting or halting or powering off or changing the outcome off the ctrl-alt-del key sequence. Yours is the power off value.

    He he, one of the constants defined to use as reboot() parameters is LINUX_REBOOT_MAGIC1 is 0xfee1dead.
    ===
    Don't grumble about what you can't have;
    be grateful you don't get what you deserve.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    4
    see the source code:

    Code:
    #define	LINUX_REBOOT_MAGIC2B	369367448
    
    #define	LINUX_REBOOT_CMD_RESTART	0x01234567
    #define	LINUX_REBOOT_CMD_HALT		0xCDEF0123
    #define	LINUX_REBOOT_CMD_CAD_ON		0x89ABCDEF
    #define	LINUX_REBOOT_CMD_CAD_OFF	0x00000000
    #define	LINUX_REBOOT_CMD_POWER_OFF	0x4321FEDC
    #define	LINUX_REBOOT_CMD_RESTART2	0xA1B2C3D4
    see the defines for reboot.
    The command which u fired 0x4321FEDC is a memory location add which forces the system to execute instruction at memory address specified above .this is usually a hard reset or in lay mans terms a power reset unlike the normal reboot where the POST(power on self test ) doesnt happens...as in the case of 0x01234567

  5. #5
    Registered Luser risby's Avatar
    Join Date
    Jun 2006
    Posts
    72
    Quote Originally Posted by linux_punk
    see the source code:

    Code:
    #define    LINUX_REBOOT_MAGIC2B    369367448
    
    #define    LINUX_REBOOT_CMD_RESTART    0x01234567
    #define    LINUX_REBOOT_CMD_HALT        0xCDEF0123
    #define    LINUX_REBOOT_CMD_CAD_ON        0x89ABCDEF
    #define    LINUX_REBOOT_CMD_CAD_OFF    0x00000000
    #define    LINUX_REBOOT_CMD_POWER_OFF    0x4321FEDC
    #define    LINUX_REBOOT_CMD_RESTART2    0xA1B2C3D4
    see the defines for reboot.
    The command which u fired 0x4321FEDC is a memory location add which forces the system to execute instruction at memory address specified above .this is usually a hard reset or in lay mans terms a power reset unlike the normal reboot where the POST(power on self test ) doesnt happens...as in the case of 0x01234567
    If those are addresses I'll eat my hat. They are ordered sequences of hex digits. Even MAGIC2B is 0x16041998, I wonder what is significant about the 16th of April 1998.
    ===
    Don't grumble about what you can't have;
    be grateful you don't get what you deserve.

  6. #6
    Registered User
    Join Date
    Oct 2004
    Posts
    151
    Maybe the Linux kernel has luggage.
    System: Debian Sid and FreeBSD 7.0. Both with GCC 4.3.

    Useful resources:
    comp.lang.c FAQ | C++ FQA Lite

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    4

    Unhappy

    Quote Originally Posted by risby
    If those are addresses I'll eat my hat. They are ordered sequences of hex digits. Even MAGIC2B is 0x16041998, I wonder what is significant about the 16th of April 1998.
    Whats there to eat ya hat...from the source code thats all i can judge !!!!!

  8. #8
    Registered Luser risby's Avatar
    Join Date
    Jun 2006
    Posts
    72
    Quote Originally Posted by linux_punk
    Whats there to eat ya hat...from the source code thats all i can judge !!!!!
    LINUX_REBOOT_CMD_RESTART 0x01234567 ---> first 8 congituous digits
    LINUX_REBOOT_CMD_HALT 0xCDEF0123 ------> last 4 contiguous digits followed by first 4
    LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF ----> last 8 contiguous digits
    LINUX_REBOOT_CMD_CAD_OFF 0x00000000 ---> all zeros or is it address of first byte of memory?
    LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC -> first 4 non-zero digits descending followed by last 4
    LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 --> alternating alpha digits with numeric digits

    Don't you think it would be a lot to ask of the operating system to have to reserve all of these particular memory addresses, jumbled as they are throughout the whole address space, so that either an instruction or possibly another address to jump to could be placed there?

    Wouldn't it be better to have your reboot code with its various options all in one place in memory.

    These are "magic numbers", simply arbitrary values that indicate different options, not addresses.
    ===
    Don't grumble about what you can't have;
    be grateful you don't get what you deserve.

  9. #9
    Registered Luser risby's Avatar
    Join Date
    Jun 2006
    Posts
    72
    Quote Originally Posted by linux_punk
    Whats there to eat ya hat...from the source code thats all i can judge !!!!!
    Ah ha!
    Code:
    #define    LINUX_REBOOT_MAGIC2B    369367448
    369367448 decimal = 16041998 hexadecimal

    16041998 could be viewed as 16th April 1998

    Linus Torvalds' second daughter, Daniela Yolanda, was born on April the 16th, 1998

    Well done, linux_punk, you made my day!
    ===
    Don't grumble about what you can't have;
    be grateful you don't get what you deserve.

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    4

    Unhappy

    Quote Originally Posted by risby
    Ah ha!
    Code:
    #define    LINUX_REBOOT_MAGIC2B    369367448
    369367448 decimal = 16041998 hexadecimal

    16041998 could be viewed as 16th April 1998

    Linus Torvalds' second daughter, Daniela Yolanda, was born on April the 16th, 1998

    Well done, linux_punk, you made my day!

    hehehe..chee thanks!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  2. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 05:35 PM
  3. New system build wont boot
    By lightatdawn in forum Tech Board
    Replies: 7
    Last Post: 12-02-2005, 06:58 AM
  4. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM
  5. Problem Reporting System. Need Advide!
    By brunomiranda in forum Tech Board
    Replies: 9
    Last Post: 09-25-2003, 09:21 PM