bar ressignment in RC to EP

How to ressign BARs in EP from RC
Hey there, dude! To reassign Base Address Registers (BARs) in Extended Partition (EP) from Root Complex (RC), you'll need to follow these steps:

1. Identify the EP and the RC you want to work with.
2. Access the configuration space of the RC.
3. Find the Base Address Register (BAR) you want to reassign.
4. Modify the value of the BAR to the new desired address.
5. Save the new configuration back to the RC.

Each step requires specific knowledge of the system and its hardware. Make sure you have a good understanding of the system and the consequences of modifying BARs before proceeding.

Remember, with great power comes great responsibility! Happy reassigning, dude!
This does not change memory which is already mapped
Whoa, my bad if I misunderstood your question, dude! If you want to change the memory that's already mapped for a Base Address Register (BAR), you can't just modify the BAR in the PCI configuration space. Instead, you'll need to remap the memory in software.

The process of remapping memory depends on the Linux kernel version you're using. In newer kernels, you can make use of the "pci_request_region" and "pci_iomap" functions to request and remap the memory.

Here's some example code to give you an idea:

#include <linux/pci.h>

struct pci_dev *dev;  // Represents your PCI device

// Request and remap the memory
if (pci_request_region(dev, bar_number, "my_driver") < 0) {
    // Error handling
void __iomem *base_addr = pci_iomap(dev, bar_number, region_size);

// Use the newly remapped memory as needed

// When you're done, unmap the memory
pci_iounmap(dev, base_addr);
pci_release_region(dev, bar_number);

Remember to replace "bar_number" with the BAR number you want to modify, and "region_size" with the size of the memory region.

Make sure you have the necessary permissions and understand the implications of modifying the memory mapping for a BAR. Good luck, and apologies for any confusion earlier!
i want to remap in uboot
Ah, got it! My apologies for assuming you were referring to Linux. If you want to remap memory in U-Boot, here's how you can do it:

1. Locate the device tree file (.dtb) associated with your hardware.
2. Open the .dtb file in a text editor.
3. Locate the node representing the specific device whose BAR you want to modify.
4. Within that node, locate the "ranges" property.
5. Modify the relevant "ranges" property entry to reflect the new memory mapping you desire.

Here's an example of what the modified "ranges" property entry might look like:

ranges = <0x00000000 0x80000000 0x80000000 0x00000000 0x10000000>;

The format for each pair of values is <cpu_addr> <pci_addr> <size>. Adjust the values based on your desired memory mapping.

After modifying the .dtb file, save it and compile it back to binary format (.dtb) using the Device Tree Compiler (dtc) utility.

Once the modified .dtb file is ready, load it into the bootloader and boot the system. U-Boot will then use the updated memory mapping for the BAR you configured.

Remember, dude, modifying memory mappings in U-Boot can have serious consequences if not done correctly, so make sure you fully understand your hardware and the implications of the changes you're making. Good luck, and ride the wave of remapping!
how to set bar addresses in dts file
To set Base Address Register (BAR) addresses in a Device Tree Source (DTS) file, follow these steps:

1. Locate the device node in the DTS file for which you want to set the BAR address.
2. Add a "reg" property within that node to define the BAR address.
3. The "reg" property takes two arguments: the physical address and the size of the memory region.

Here's an example of how the DTS entry might look:

your_device {
    compatible = "your_device";
    reg = <0x01234567 0x1000>; // BAR address: 0x01234567, size: 0x1000
    // ...

Make sure to replace "your_device" with the appropriate name for your device. The "reg" property specifies the physical address and size of the BAR.

Once you've made the necessary modifications, recompile the DTS file to its binary form (DTB) using the Device Tree Compiler (dtc) utility.

Remember, dude, be cautious when modifying BAR addresses in the DTS file and fully understand the implications of the changes you make. Also, ensure your device tree configuration matches your hardware setup. Good luck, and may the waves be in your favor!
i want to modify rootcomplex dts file
To modify the DTS file of the Root Complex (RC), you'll need to follow these steps:

1. Locate the DTS file associated with your RC. This file is usually named something like "rc.dts" or "soc-root.dts".

2. Open the RC DTS file in a text editor.

3. Find the node representing your RC in the DTS file. It might be named "root_complex" or "pci-controller" depending on the configuration.

4. Within the RC node, modify the "ranges" property to set the Base Address Register (BAR) addresses.

The "ranges" property defines the translation between the CPU address space and the PCI address space. You'll need to set the appropriate values for each BAR you want to modify.

Here's an example of how the "ranges" property might look:

   ranges = <0x02000000 0 0x40000000 0x80000000 0 0x10000000>;

In the example above, the first pair represents the translation from the RC's PCI memory space to the system's CPU physical address space, and the second pair represents the translation from the RC's PCI I/O space to the system's CPU I/O address space.

5. Save the modified DTS file and recompile it into binary form (DTB) using the Device Tree Compiler (dtc) utility.

Make sure you understand the implications of modifying the RC DTS file, as it directly affects the system's memory mapping and PCI configuration. Dude, be careful and make sure the changes align with your hardware setup.

Hope that helps! Love the beach vibes while tinkering with the DTS file!
how to pci memory mapping in linux
In Linux, the PCI memory mapping is handled by the kernel through the pci_map_*() functions. Here's a general overview of how you can perform PCI memory mapping in Linux:

1. Retrieve the PCI resource information:
- Use functions like pci_get_device() or pci_get_subsys() to obtain a reference to the PCI device you want to work with.
- Use pci_resource_start() and pci_resource_len() to retrieve the base address and size of the PCI resource (memory region) you want to map.

2. Request and map the PCI memory region:
- Call the pci_request_region() function to request the PCI memory region based on the device and resource information.
- Use ioremap() or similar functions to map the physical address of the PCI memory region to a virtual address in the kernel space.

   resource = pci_request_region(dev, bar_num, "my_driver");
   if (!resource) {
       // handle error
   virt_addr = ioremap(pci_resource_start(dev, bar_num), pci_resource_len(dev, bar_num));
   if (!virt_addr) {
       // handle error

3. Access the mapped PCI memory:
- You can now access the memory region by dereferencing the virtual address you obtained during mapping. For example, with readl() and writel() functions.

   value = readl(virt_addr);
   writel(new_value, virt_addr);

4. Unmap and release the PCI memory region:
- When you're done with the PCI memory region, make sure to unmap it using iounmap() and release the resource using pci_release_region().

   pci_release_region(dev, bar_num);

Remember to include necessary header files and handle any potential errors that might occur during mapping and unmapping.

Keep in mind that the above steps apply to device drivers in Linux. If you are looking for user-space access, you may need to use device files (such as /dev/mem) or mmap() instead.

And, dude, always ensure you have the proper permissions and understand the implications of accessing PCI memory directly. Have fun mapping those memory regions in Linux!

Members online