How to calculate the linux kernel 0x07c0 address? - linux

I am reading a book about linux.It says the address 0x7c00 is about 31K.I want to know how to get the 31K according to address.The code is:mov ax,#BOOTSEG.Which #BOOTSEG is 0x07c0.I have already search from internet.

Related

data transfer from PL(fpga) to the PC via ethernet

I work with Zedboard and vivado v2017.3.
I have a custom IP in the PL part of zynq generating 32 bit values and stores them in one of the registers, say slv_reg0 (address : 0x43c00000).
In the PS part I read this register and I can print it in the gtkterm (simple one).
I now want to transmit these values over ethernet to to the PC.
Any suggestion on how to carry out this?
Thanks,
Upasana.
Xilinx supplies sample programs, one of these is an echo server. It should be quite simple to change it so that it serves the data you generate instead of just echo-ing the received message, and you can learn out of it how to use the lwip library in case you want a more suitable solution.

Write a system call as a kernel module

I have been given an assignment to "Write a system call as a kernel module". Now as far as I could understand from my reading on the internet, it is not exactly possible to implement a system call as a kernel module, however there are ways to intercept the existing system calls. Is this the right way to do it ?
I found one such example on this blog: http://syprog.blogspot.in/2011/10/hijack-linux-system-calls-part-i.html
In linux sys_call_table contains function pointers for all system calls. This table was initially exported back in the days of 2.4 , then it was made static , then again it was exported in of some of latest kernels.Lets take example of two cases.
Case 1. sys_call_table exported.
Use following line in your kernel module.
sys_call_table[AVAILABLE_INDEX] = new_sys_call;
New system call can be implemented as.
asmlinkage new_sys_call(...) { }
Case - 2) sys_call_table not exported.
Try getting sys_call_table address by grepping in System.map
$cat System.map|grep sys_call_table
Hard code the value in your module.
If that is not available , then we need to determine the table address dynamically.
sys_call_table most likely be there in the beginning of kernel text section.
Here are steps to compute base address of sys_call_table
Find two system calls which are placed next to each other in the
table(from source code). For ex: sys_read , sys_open.
Get address of these sys calls.
Search these two addresses from the beginning of text section.
(Compute start of text section by , objdump -h vmlinux|grep ".text")
When you found it , compute the base of sys_call_table , based on
their relative offset.

mpc85xx(P2040) startup using Nor Flash, where is Nor Flash mapped to?

I'm porting u-boot to P2040 based board these days.
As u-boot/arch/powerpc/mpc85xx/start.s commented:
The processor starts at 0xffff_fffc and the code is first executed in the last 4K page in flash/rom.
In u-boot/arch/powerpc/mpc85xx/resetvec.S:
.section .resetvec,"ax"
b _start_e500
And in u-boot.lds linker script:
.resetvec RESET_VECTOR_ADDRESS :
{
KEEP(*(.resetvec))
} :text = 0xffff
The reset vector is at 0xffff_fffc, which contains a jump instruction to _start_e500.
The E500MCRM Chapter 6.6 mentioned:
This default TLB entry translates the first instruction fetch out of reset(at effective address 0xffff_fffc).
This instruction should be a branch to the beginning of this page.
So, if I configure the HCW to let powerpc boot from Nor Flash, why should I suppose that the Nor Flash's
last 4K is mapped to 0xffff_f000~0xffff_ffff? Since there're no LAW setup yet and the default BR0/OR0 of Local Bus
does not match that range. I’m confused about how Nor Flash be access at the very beginning of core startup.
Another question is:
Does P2040 always have MMU enabled so as to translate effective address to real address even at u-boot stage?
If so, beside accessing to CCSRBAR, all other memory access should have TLB entry setup first.
Best Regards,
Hook Guo

Using /proc/[pid]/pagemap

I am aware that there is a little information regarding the pagemap file here. But nobody seems to indicate how to reference entries in the file. Is it offset by virtual address? Can I take a virtual address VA and simply lseek to offset VA? Or is it by page? If so, how do I retrieve the page number, as maps simply lists them in order. I am trying to translate between virtual and physical addresses, and lseek'ing with the virtual address as the offset always returns the same number, no matter where I seek to.
Thanks
#leeduhem: Yes I have. Here's the relevant part:
3. Open /proc/pid/pagemap and seek to the pages you would like to examine.
4. Read a u64 for each page from pagemap.
That doesn't help me. It wants me to seek to the page, but how do I know where the entry for the page is?
There is a tool that will help you to get information you need from the pagemap file.
http://fivelinesofcode.blogspot.com/2014/03/how-to-translate-virtual-to-physical.html
You divide the virtual address by the pagesize (normally 0x1000 or 4096) and use that to index in /proc/self/pagemap. After the division, that's known as the PFN, or page frame number.
Larry

where does iwconfig get data on bitrate in linux

I am writing a C program to calculate current bandwidth usage on a data link. I also need the bandwidth of the link.
For wireless links, iwconfig prints the wireless link characteristics which are stored in /proc/net/wireless. However how about data rate of the wireless link? Is it also stored somewhere in the (another)file?
Also for ethernet links, Are there similar files where all the link details are stored?
You should use libnl to query interface information. Don't rely on files under /proc or scrape the output of iw or iwconfig, since their output format might change any time.
If you are curious about the details, check out the source code of iw. It's easy to understand (I used it myself to understand how to query nl80211 for interface info).
So, I solved my problem by reading the tx_bytes and rx_bytes in the statistics directory of each interface. My function is called every 10 seconds. so, I save the current value of tx/rx_bytes in memory and when my function is called the next time, i use the current value and previous value to calculate the data rate.

Resources