On Sat, 2 Oct 2004 11:38:44 +0100 (BST), Dinesh Ahuja <mdlinux7@xxxxxxxxxxx> wrote: > I [being a chemical enginner and new to Kernel world ] > am having probelm in understanding a sample code > [skull] available with Book Linux device driver By > Alessandro Rubini. Could anyone guide me about this ? > mb(); [ What mb do ?. Memory Barrier. It enforced in-order execution of memory accesses either side of this function call - so you guarantee everything got done that you asked for. Intel people don't (I think, but I don't do Intel stuff very often) generally have to worry about this even on the latest cores because any instruction re-ordering is transparent to the programmer. On RISC based machines such as Sparc International (Sun) SPARC, AIM PowerPC, IBM POWER, and so on, we have to handle the fact that memory accesses may be re-ordered by both the compiler and/or the micro itself in order to streamline the processor instruction pipeline. There are various books which go in to this at some length. Aside from the regular Linux kernel books, I also hear good things about the following (although I have them, I've not yet read them exhaustively): *). Computer Architecture: A Quantitative Approach (aka CAAQA. The big book). *). SPARC Architecture, Assembly language programming, and C. (SPARC orientated). > Is documentation present for these functions ] Perhaps there are manual pages somewhere. The reality is that you end up reading kernel books to figure out what these things do or have them explained ahead of time, as was the case when I started reading various books on the subject. > I got the programming aspect for this but did not get > the logic of it. > if ((oldval^newval) == 0xff) { /* we re-read our > change: it's ram */ > printk(KERN_INFO "%lx: RAM\n", add); > continue; > } > > if ((oldval^newval) != 0) { /* random bits changed: > it's empty */ > printk(KERN_INFO "%lx: empty\n", add); > continue; > } > > Please explain these lines and what is the > significance of Expansion ROM. You'll have to provide a reference to the C source file where you saw these functions. Looks like a test to see what kind of memory is at a certain address - if you write data to a memory location then it will change unless it is ROM, but if it is then it will return the same value every time that you read it. If there is nothing at a particular address then you will read only random data according to whatever electical state the memory bus is in - apparently sometimes you can actually read a valid value back if your memory bus has some capacitve issue where it acts like a register itself (but that's rarely a problem these days - it is however enough for me/us to take special measures in our memory test routines at work). Jon. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/