Posts

Showing posts from 2024

bashrc

#!/bin/bash iatest=$(expr index "$-" i) ####################################################### # SOURCED ALIAS'S AND SCRIPTS BY zachbrowne.me ####################################################### # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # Enable bash programmable completion features in interactive shells if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi ####################################################### # EXPORTS ####################################################### # Disable the bell if [[ $iatest > 0 ]]; then bind "set bell-style visible"; fi # Expand the history size export HISTFILESIZE=10000 export HISTSIZE=500 # Don't put duplicate lines in the history and do not add lines that start with a space export HISTCONTROL=erasedups:ignoredups:ignorespace # Check the window size after each com...

kernel-misc

 __init and __exit attributes __init and __exit are kernel macros, defined in include/linux/init.h, as shown here: #define __init #define __exit __section(.init.text) __section(.exit.text) __init and __exit are Linux directives (macros) that wrap GNU C compiler attributes used for symbol placement. They instruct the compiler to put the code they prefix in the .init.text and .exit.text sections. This applies only to built-in modules, not to loadable ones A kernel module uses its .modinfo section to store information about the module. Any MODULE_* macro will update the content of this section with the values passed as  parameters. You can dump the content of the .modeinfo section of a kernel module using the objdump -d -j .modinfo

kernel-power-management

 There are two types of power management that the operating system must handle:  Device Power Management and, System Power Management. Device power management is an alias for the so-called Runtime Power Management. This may allow, among other things, part of the device not currently in use to be turned off in order to conserve power, such as the keyboard backlight when you are not typing. System Power Management, also known as Sleep States: This enables platforms to enter a system-wide low-power state. dynamic power management interfaces: CPU Idle: Whenever a logical CPU in the system has no task to execute, it may need to be put in a particular state in order to save power. In this situation, most operating systems simply schedule a so-called idle thread. While executing this thread, the CPU is said to be idle, or in an idle state. CPU Idle is a framework that manages idle threads. There are several levels (or modes or states) of idling. It depends o...

kernel-memory

 page - fixed length (PAGE_SIZE) block of virtual memory. page frame - fixed-length block of physical memory (RAM) page table - mappings between virtual addresses and physical addresses --------------------------------------------------------------------------------- 128 MB of the kernel address space is used to map a high memory of RAM on the fly when needed.  Mapping to access high memory is created on the fly by the kernel and destroyed when done. This makes high memory access slower. However, the concept of high memory does not exist on 64-bit systems, due to the huge address range (264 TB), where the 3 GB/1 GB (or any similar split scheme) split does not make sense anymore. On the other hand, 896 MB of kernel address space is permanently and linearly mapped to a low 896 MB of RAM. Addresses that result from that mapping are called logical addresses. These are virtual addresses but can be translated into physical addresses by subtracting a fixed offset. the first 16 MB of ...

gpio-descriptor-based

 https://github.com/PacktPublishing/Linux-Device-Drivers-Development/blob/master/Chapter14/gpio-descriptor-module.c https://www.embedded.com/linux-device-driver-development-the-descriptor-based-gpio-interface/ struct gpio_chip { const char *label; struct gpio_device *gpiodev; struct device *parent; struct fwnode_handle *fwnode; struct module *owner; int (*request)(struct gpio_chip *gc, unsigned int offset); void (*free)(struct gpio_chip *gc, unsigned int offset); int (*get_direction)(struct gpio_chip *gc, unsigned int offset); int (*direction_input)(struct gpio_chip *gc, unsigned int offset); int (*direction_output)(struct gpio_chip *gc,  unsigned int offset, int value); int (*get)(struct gpio_chip *gc, unsigned int offset); int (*get_multiple)(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits); void (*set)(struct gpio_chip *gc, unsigned int offset, int value); void (*set_multiple)(struct...

extranotes

 b) Reserve 1 Mbyte of kernel memory for your driver (Similar to PSTORE)  root@apalis-imx8:~$ cat /proc/iomem .... 8020_0000-83ffffff : System RAM 8028_0000-8161ffff : Kernel code 8162_0000-8188ffff : reserved 8189_0000-81a85fff : Kernel data 8640_0000-87ffffff : System RAM 9000_0000-901fffff : System RAM 9050_0000-91ffffff : System RAM 94c0_0000-94ffffff : System RAM 9540_0000-ffffffff : System RAM 9600_0000-d1ffffff : reserved f960_3000-fd62afff : reserved 8_8000_0000-8ffffffff : System RAM 8_fae0_0000-8fb5fffff : reserved 8_fb7f_e000-8ff5fffff : reserved 8_ff6d_b000-8ff73afff : reserved 8_ff73_b000-8ff73bfff : reserved 8_ff73_c000-8ff7cbfff : reserved 8_ff7c_e000-8ff7cefff : reserved 8_ff7c_f000-8ff7d3fff : reserved 8_ff7d_4000-8ff7d4fff : reserved 8_ff7d_5000-8ffffffff : reserved    check available memory of 1 MB which is not reserved, e.g. 8_8000_0000 Now in device tree    pstore and ramoops The ramoops driver allows us to store k...

dma-theory-linux

 1) Requesting a DMA channel: dma_request_channel(const dma_cap_mask_t *mask,dma_filter_fn fn, void *fn_param); 2)Configurintg the DMA channel: dmaengine_slave_config(struct dma_chan *chan,struct dma_slave_config *config); 2)Configuring the DMA transfer: dmaengine_prep_dma_memcpy(my_dma_chan,dma_dst_addr, dma_src_addr, BUFFER_SIZE, 0); 3)Submitting the DMA transfer: dmaengine_submit(struct dma_async_tx_descriptor *desc); 4)Issue pending DMA requests and wait for callback dma_async_issue_pending(struct dma_chan *chan); https://elixir.bootlin.com/linux/latest/source/drivers/dma/sh/rcar-dmac.c https://android.googlesource.com/kernel/msm/+/android-msm-marlin-3.18-nougat-dr1/drivers/dma/imx-sdma.c ---------------------------------------------------------------------- The direct memory access (DMA) is a feature that allows some hardware subsystems to access memory independently from the central processing unit (CPU). The DMA can transfer ...