Added missing local statement.
Merge pull request #32 from pkazmier/master

Fixed Lua newbie bugs with forgetting `local` keyword on some local variables.
Added HugeTLB support for allocating DMA memory.

New API:
  memory.dma_alloc(bytes) => ptr, actualbytes
allocates physically contiguous memory from one HugeTLB page.

The memory is allocated with the mmap() flag MAP_HUGETLB.

If allocation fails then the code audaciously asks the kernel to
provision a new HugeTLB page and tries again. This is done by
increasing /proc/sys/vm/nr_hugepages. If you would like to free up
those huge pages after you're done running snabbswitch then you can do:
  echo 0 > /proc/sys/vm/nr_hugepages
and the memory will go back into circulation.

Expect another commit soon to replace the quick hack of hard-coding
the expected HugeTLB page size.

Here is a transcript of the updated selftest function:

    selftest: memory
    Kernel HugeTLB pages (/proc/sys/vm/nr_hugepages): 0
      Allocating 1MB from a HugeTLB page: cdata<void *>: 0x7fb083600000, 1048576
      Allocating 1MB from a HugeTLB page: cdata<void *>: 0x7fb083800000, 1048576
      Allocating 1MB from a HugeTLB page: cdata<void *>: 0x7fb083a00000, 1048576
      Allocating 1MB from a HugeTLB page: cdata<void *>: 0x7fb083c00000, 1048576
    Kernel HugeTLB pages (/proc/sys/vm/nr_hugepages): 4
    HugeTLB page allocation OK.
Bad idea: Lookup actual HugeTLB page size via /proc/self/pagemap.

Bad idea because it doesn't work: the file reports 4096 even for huge
pages. Committed just in case this code should be dug up some day for
some other purpose.

The next commits will rollback these changes and add a better solution.
Revert "Bad idea: Lookup actual HugeTLB page size via /proc/self/pagemap."

This reverts commit 03c248c1a9a9e1f563f4fb923a2b4c5f7920bf06.
lib.lua: Added readfile() and writefile().
memory.lua: Lookup HugeTLB size by groveling /proc/meminfo.

Had been an unreliable constant.
memory.lua: Use lib.{readfile,writefile} to simplify {get,set}_hugepages.
memory.lua: dma_alloc() now returns physical address too.

API: memory.dma_alloc(size) => pointer, physaddr, actualsize

Removed the cache from map() results since now callers can probably
remember the physical address themselves instead of looking it up all
the time.
memory.lua: dma_alloc() now returns physical address as a Lua number.

This "should be OK" provided that physical addresses fit in 52 bits of
precision which I think they do on machines with less than petabytes
of memory. (Certainly not the last word on this topic....)
intel.lua: Use memory.dma_alloc() instead of C.map_physical_ram.

Hurray! Snabb Switch now runs on a standard Linux with no special boot
parameters. You can retire your "memmap=..." grub lines.
intel.lua: Removed unused constants.

This file is overdue for some heavy cleanup.
memory.lua: Removed old selftest code based on map_physical_ram.
pci.lua, selftest.lua: Check that pci.prepare_device() really succeeds.
intel.lua: Added selftest_tso() test case for TCP Segmentation Offload.

Just a failing test for now because TSO is not yet implemented.

Progress on issue #33.
Fixed register address offset for ICR.
Merge pull request #36 from pkazmier/master

Looks like a small typo in one of the register address offsets.