hardware manipulation with pointers

This is a discussion on hardware manipulation with pointers within the Tech Board forums, part of the Community Boards category; what can be done with this?...

  1. #1
    Registered User TheSupremeAbode's Avatar
    Join Date
    Jan 2011
    Location
    Portland, OR
    Posts
    10

    hardware manipulation with pointers

    what can be done with this?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,548
    That really depends on the hardware, and whatever OS lies between your program and the "bare metal".

    If you're on a simple PIC/AVR for example, and writing say 0x55 to a memory location causes a row of 8 LED's to alternately light up, then that's one end of the spectrum.

    If you're on a regular desktop with an OS that gives each user process a virtualised environment, then you have to rely on the OS to give you a specific API to do specific things to the hardware. For example, you can write to a disk via the file system, but you can't just randomly choose a sector and scribble anything you want. You can do a bit more damage with 'root' privileges, but you're still somewhat constrained by what the OS drivers may allow you to do.
    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. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,307
    Anything and nothing.

    Anything in the sense that, with a pointer of an appropriate value, it is possible to communicate directly with hardware. Of course, you have to know the actual addresses that a given piece of hardware uses to communicate. Specifically, if you are attempting to send data or commands to a particular item of hardware, then you need to know what memory locations (if any) that hardware listens to. Similarly, if you are attempting to receive data from a particular item of hardware, you need to know what memory locations (if any) that hardware writes data to. You also need to know the meaning of particular data at that specified memory location, in order to either make a meaningful request or to interpret the response.

    Nothing in the sense that there is more to communicating with hardware than stuffing data into, or sucking data from, a memory location - which is all that is really possible with pointers. Not all hardware communicates through memory locations that are accessible via pointers. Modern operating systems (windows, unix, etc) are specifically designed to prevent software from directly communicating with hardware - it is necessary to use some API or other means to make a request of the operating system which, if it so chooses, then passes the request onto the relevant hardware. Because of that, software that attempts to manipulate hardware in untoward ways often finds itself being stopped (for example, modern operating systems routinely terminate program that are detected in an attempt to access a memory location it shouldn't).
    Right 98% of the time, and don't care about the other 3%.

  4. #4
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    >what can be done with this?
    Itís like asking Iíve got bread and butter, what can I do with it?

    Well, the one powerful use of pointer is that, it can point anywhere in the memory to either read and write (assuming that intermediate OS not in use, like in some embedded systems). There are set of GPIO devices which might be mapped to a processor register, writing to those registers is literally altering power levels at the target GPIO devices. At the any of the day, anything you want to control through program would have been connected to some sort of registers which either your program writes directly to the registers or you memory map the register to a memory block. Writing to the memory block which in turn writes it to the registers, resulting in some action taking place on the connected hardware.

    ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 01-04-2011, 05:42 PM
  2. C for Hardware
    By biggiebigzz in forum Tech Board
    Replies: 2
    Last Post: 09-26-2007, 12:01 PM
  3. USB hardware...
    By Coder87C in forum Windows Programming
    Replies: 0
    Last Post: 03-10-2004, 10:10 PM
  4. hardware
    By onurak in forum C++ Programming
    Replies: 3
    Last Post: 07-18-2002, 08:36 PM
  5. anyone is well in hardware ?
    By black in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 06-27-2002, 04:22 AM

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