├── .github └── workflows │ └── main.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── README_BOOTLOGO.md ├── Versions.inc ├── bdk ├── bdk.h ├── display │ ├── di.c │ ├── di.h │ ├── di.inl │ ├── vic.c │ └── vic.h ├── exception_handlers.S ├── fatfs_cfg.h ├── fatfs_conf.h ├── gfx_utils.h ├── ianos │ ├── elfload │ │ ├── elf.h │ │ ├── elfarch.h │ │ ├── elfload.c │ │ ├── elfload.h │ │ ├── elfreloc_aarch64.c │ │ └── elfreloc_arm.c │ ├── ianos.c │ └── ianos.h ├── input │ ├── als.c │ ├── als.h │ ├── joycon.c │ ├── joycon.h │ ├── touch.c │ └── touch.h ├── libs │ ├── compr │ │ ├── blz.c │ │ ├── blz.h │ │ ├── lz.c │ │ ├── lz.h │ │ ├── lz4.c │ │ └── lz4.h │ ├── fatfs │ │ ├── diskio.h │ │ ├── ff.c │ │ ├── ff.h │ │ ├── ffsystem.c │ │ └── ffunicode.c │ ├── lv_conf.h │ └── lvgl │ │ ├── docs │ │ ├── CODE_OF_CONDUCT.md │ │ ├── CONTRIBUTING.md │ │ ├── astyle_c │ │ └── astyle_h │ │ ├── licence.txt │ │ ├── lv_core │ │ ├── lv_core.mk │ │ ├── lv_group.c │ │ ├── lv_group.h │ │ ├── lv_indev.c │ │ ├── lv_indev.h │ │ ├── lv_lang.c │ │ ├── lv_lang.h │ │ ├── lv_obj.c │ │ ├── lv_obj.h │ │ ├── lv_refr.c │ │ ├── lv_refr.h │ │ ├── lv_style.c │ │ ├── lv_style.h │ │ ├── lv_vdb.c │ │ └── lv_vdb.h │ │ ├── lv_draw │ │ ├── lv_draw.c │ │ ├── lv_draw.h │ │ ├── lv_draw.mk │ │ ├── lv_draw_arc.c │ │ ├── lv_draw_arc.h │ │ ├── lv_draw_img.c │ │ ├── lv_draw_img.h │ │ ├── lv_draw_label.c │ │ ├── lv_draw_label.h │ │ ├── lv_draw_line.c │ │ ├── lv_draw_line.h │ │ ├── lv_draw_rbasic.c │ │ ├── lv_draw_rbasic.h │ │ ├── lv_draw_rect.c │ │ ├── lv_draw_rect.h │ │ ├── lv_draw_triangle.c │ │ ├── lv_draw_triangle.h │ │ ├── lv_draw_vbasic.c │ │ └── lv_draw_vbasic.h │ │ ├── lv_fonts │ │ ├── harmony_os_sans_20.c │ │ ├── harmony_os_sans_30.c │ │ ├── hekate_symbol_120.c │ │ ├── hekate_symbol_20.c │ │ ├── hekate_symbol_30.c │ │ ├── interui_20.c │ │ ├── interui_30.c │ │ ├── lv_font_builtin.c │ │ ├── lv_font_builtin.h │ │ ├── lv_fonts.mk │ │ └── ubuntu_mono.c │ │ ├── lv_hal │ │ ├── lv_hal.h │ │ ├── lv_hal.mk │ │ ├── lv_hal_disp.c │ │ ├── lv_hal_disp.h │ │ ├── lv_hal_indev.c │ │ ├── lv_hal_indev.h │ │ ├── lv_hal_tick.c │ │ └── lv_hal_tick.h │ │ ├── lv_misc │ │ ├── lv_anim.c │ │ ├── lv_anim.h │ │ ├── lv_area.c │ │ ├── lv_area.h │ │ ├── lv_circ.c │ │ ├── lv_circ.h │ │ ├── lv_color.c │ │ ├── lv_color.h │ │ ├── lv_font.c │ │ ├── lv_font.h │ │ ├── lv_fs.c │ │ ├── lv_fs.h │ │ ├── lv_gc.c │ │ ├── lv_gc.h │ │ ├── lv_ll.c │ │ ├── lv_ll.h │ │ ├── lv_log.c │ │ ├── lv_log.h │ │ ├── lv_math.c │ │ ├── lv_math.h │ │ ├── lv_mem.c │ │ ├── lv_mem.h │ │ ├── lv_misc.mk │ │ ├── lv_symbol_def.h │ │ ├── lv_task.c │ │ ├── lv_task.h │ │ ├── lv_templ.c │ │ ├── lv_templ.h │ │ ├── lv_txt.c │ │ ├── lv_txt.h │ │ ├── lv_ufs.c │ │ └── lv_ufs.h │ │ ├── lv_objx │ │ ├── lv_arc.c │ │ ├── lv_arc.h │ │ ├── lv_bar.c │ │ ├── lv_bar.h │ │ ├── lv_btn.c │ │ ├── lv_btn.h │ │ ├── lv_btnm.c │ │ ├── lv_btnm.h │ │ ├── lv_calendar.c │ │ ├── lv_calendar.h │ │ ├── lv_canvas.c │ │ ├── lv_canvas.h │ │ ├── lv_cb.c │ │ ├── lv_cb.h │ │ ├── lv_chart.c │ │ ├── lv_chart.h │ │ ├── lv_cont.c │ │ ├── lv_cont.h │ │ ├── lv_ddlist.c │ │ ├── lv_ddlist.h │ │ ├── lv_gauge.c │ │ ├── lv_gauge.h │ │ ├── lv_img.c │ │ ├── lv_img.h │ │ ├── lv_imgbtn.c │ │ ├── lv_imgbtn.h │ │ ├── lv_kb.c │ │ ├── lv_kb.h │ │ ├── lv_label.c │ │ ├── lv_label.h │ │ ├── lv_led.c │ │ ├── lv_led.h │ │ ├── lv_line.c │ │ ├── lv_line.h │ │ ├── lv_list.c │ │ ├── lv_list.h │ │ ├── lv_lmeter.c │ │ ├── lv_lmeter.h │ │ ├── lv_mbox.c │ │ ├── lv_mbox.h │ │ ├── lv_objx.mk │ │ ├── lv_objx_templ.c │ │ ├── lv_objx_templ.h │ │ ├── lv_page.c │ │ ├── lv_page.h │ │ ├── lv_preload.c │ │ ├── lv_preload.h │ │ ├── lv_roller.c │ │ ├── lv_roller.h │ │ ├── lv_slider.c │ │ ├── lv_slider.h │ │ ├── lv_spinbox.c │ │ ├── lv_spinbox.h │ │ ├── lv_sw.c │ │ ├── lv_sw.h │ │ ├── lv_ta.c │ │ ├── lv_ta.h │ │ ├── lv_table.c │ │ ├── lv_table.h │ │ ├── lv_tabview.c │ │ ├── lv_tabview.h │ │ ├── lv_tileview.c │ │ ├── lv_tileview.h │ │ ├── lv_win.c │ │ └── lv_win.h │ │ ├── lv_themes │ │ ├── lv_theme.c │ │ ├── lv_theme.h │ │ ├── lv_theme_hekate.c │ │ ├── lv_theme_hekate.h │ │ └── lv_themes.mk │ │ ├── lv_version.h │ │ ├── lvgl.h │ │ └── lvgl.mk ├── mem │ ├── emc.h │ ├── heap.c │ ├── heap.h │ ├── mc.c │ ├── mc.h │ ├── mc_t210.h │ ├── minerva.c │ ├── minerva.h │ ├── mtc_table.h │ ├── sdram.c │ ├── sdram.h │ ├── sdram_config.inl │ ├── sdram_config_t210b01.inl │ ├── sdram_param_t210.h │ ├── sdram_param_t210b01.h │ ├── smmu.c │ └── smmu.h ├── memory_map.h ├── module.h ├── power │ ├── bm92t36.c │ ├── bm92t36.h │ ├── bq24193.c │ ├── bq24193.h │ ├── max17050.c │ ├── max17050.h │ ├── max77620.h │ ├── max7762x.c │ ├── max7762x.h │ ├── max77812.h │ ├── regulator_5v.c │ └── regulator_5v.h ├── rtc │ ├── max77620-rtc.c │ └── max77620-rtc.h ├── sec │ ├── se.c │ ├── se.h │ ├── se_t210.h │ ├── tsec.c │ ├── tsec.h │ └── tsec_t210.h ├── soc │ ├── actmon.c │ ├── actmon.h │ ├── bpmp.c │ ├── bpmp.h │ ├── ccplex.c │ ├── ccplex.h │ ├── clock.c │ ├── clock.h │ ├── fuse.c │ ├── fuse.h │ ├── gpio.c │ ├── gpio.h │ ├── hw_init.c │ ├── hw_init.h │ ├── i2c.c │ ├── i2c.h │ ├── irq.c │ ├── irq.h │ ├── kfuse.c │ ├── kfuse.h │ ├── pinmux.c │ ├── pinmux.h │ ├── pmc.c │ ├── pmc.h │ ├── pmc_lp0_t210.h │ ├── t210.h │ ├── timer.c │ ├── timer.h │ ├── uart.c │ └── uart.h ├── storage │ ├── emmc.c │ ├── emmc.h │ ├── mbr_gpt.h │ ├── mmc.h │ ├── nx_emmc_bis.c │ ├── nx_emmc_bis.h │ ├── ramdisk.c │ ├── ramdisk.h │ ├── sd.c │ ├── sd.h │ ├── sd_def.h │ ├── sdmmc.c │ ├── sdmmc.h │ ├── sdmmc_driver.c │ ├── sdmmc_driver.h │ └── sdmmc_t210.h ├── thermal │ ├── fan.c │ ├── fan.h │ ├── tmp451.c │ └── tmp451.h ├── usb │ ├── usb_descriptor_types.h │ ├── usb_descriptors.c │ ├── usb_gadget_hid.c │ ├── usb_gadget_ums.c │ ├── usb_t210.h │ ├── usbd.c │ ├── usbd.h │ └── xusbd.c └── utils │ ├── aarch64_util.h │ ├── btn.c │ ├── btn.h │ ├── dirlist.c │ ├── dirlist.h │ ├── ini.c │ ├── ini.h │ ├── list.h │ ├── sprintf.c │ ├── sprintf.h │ ├── types.h │ ├── util.c │ └── util.h ├── bootloader ├── config.c ├── config.h ├── frontend │ ├── fe_info.c │ ├── fe_info.h │ ├── fe_tools.c │ └── fe_tools.h ├── gfx │ ├── gfx.c │ ├── gfx.h │ ├── logos.c │ ├── logos.h │ ├── tui.c │ └── tui.h ├── hos │ ├── hos.c │ ├── hos.h │ ├── hos_config.c │ ├── hos_config.h │ ├── pkg1.c │ ├── pkg1.h │ ├── pkg2.c │ ├── pkg2.h │ ├── pkg2_ini_kippatch.c │ ├── pkg2_ini_kippatch.h │ ├── pkg2_patches.inl │ ├── pkg3.c │ ├── pkg3.h │ ├── secmon_exo.c │ └── secmon_exo.h ├── l4t │ ├── l4t.c │ ├── l4t.h │ └── l4t_config.inl ├── libs │ └── fatfs │ │ ├── diskio.c │ │ └── ffconf.h ├── link.ld ├── main.c ├── start.S └── storage │ ├── emummc.c │ └── emummc.h ├── loader ├── Makefile ├── link.ld ├── loader.c └── start.S ├── modules ├── hekate_libsys_lp0 │ ├── Makefile │ ├── pmc_lp0_t210.h │ ├── sdram_lp0_param_t210.h │ ├── sdram_lp0_param_t210b01.h │ ├── sys_sdramlp0.c │ ├── t210.h │ └── types.h ├── hekate_libsys_minerva │ ├── Makefile │ ├── README.md │ ├── mtc.h │ ├── mtc_mc_emc_regs.h │ ├── mtc_switch_tables.h │ ├── mtc_table.h │ ├── sys_sdrammtc.c │ └── types.h └── simple_sample │ ├── Makefile │ ├── gfx │ ├── gfx.c │ └── gfx.h │ └── module_sample.c ├── nyx ├── Makefile ├── README_RES.md ├── nyx_gui │ ├── config.c │ ├── config.h │ ├── frontend │ │ ├── fe_emmc_tools.c │ │ ├── fe_emmc_tools.h │ │ ├── fe_emummc_tools.c │ │ ├── fe_emummc_tools.h │ │ ├── gui.c │ │ ├── gui.h │ │ ├── gui_emmc_tools.c │ │ ├── gui_emmc_tools.h │ │ ├── gui_emummc_tools.c │ │ ├── gui_emummc_tools.h │ │ ├── gui_info.c │ │ ├── gui_info.h │ │ ├── gui_options.c │ │ ├── gui_options.h │ │ ├── gui_tools.c │ │ ├── gui_tools.h │ │ ├── gui_tools_partition_manager.c │ │ └── gui_tools_partition_manager.h │ ├── gfx │ │ ├── gfx.c │ │ ├── gfx.h │ │ └── logos-gui.h │ ├── hos │ │ ├── hos.c │ │ ├── hos.h │ │ ├── pkg1.c │ │ ├── pkg1.h │ │ ├── pkg2.c │ │ └── pkg2.h │ ├── libs │ │ └── fatfs │ │ │ ├── diskio.c │ │ │ └── ffconf.h │ ├── link.ld │ ├── nyx.c │ └── start.S └── resources │ ├── icon_lakka.bmp │ ├── icon_lakka_hue.bmp │ ├── icon_payload.bmp │ └── icon_switch.bmp ├── res ├── bootlogo │ ├── bootA_(ARGB).bmp │ ├── bootA_caps_(ARGB).bmp │ ├── bootA_custom_(ARGB).bmp │ ├── bootB_(ARGB).bmp │ ├── bootB_caps_(ARGB).bmp │ ├── bootB_custom_(ARGB).bmp │ ├── bootC_(ARGB).bmp │ ├── bootC_ctc_(ARGB).bmp │ ├── bootD_(ARGB).bmp │ ├── bootD_ctc_(ARGB).bmp │ └── bootlogo.psd ├── hekate_ipl_template.ini └── patches_template.ini └── tools ├── bin2c ├── Makefile └── bin2c.c ├── emc.def ├── find_chinese.py ├── fix_regs.py ├── lz ├── Makefile ├── lz.c ├── lz.h └── lz77.c ├── mc.def └── smmu_payload.py /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build Hekate 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | container: 15 | image: devkitpro/devkita64 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | 20 | - name: Install Essential Build Tools and Utilities 21 | run: | 22 | sudo apt-get update 23 | sudo apt-get install -y build-essential jq unzip zip 24 | 25 | - name: Build hekate 26 | run: | 27 | make 28 | 29 | - name: Download latest hekate_ctcaer release 30 | id: download 31 | run: | 32 | # Get the latest release tag name and asset name 33 | RELEASE_DATA=$(curl --silent "https://api.github.com/repos/CTCaer/hekate/releases/latest") 34 | TAG_NAME=$(echo "$RELEASE_DATA" | jq -r .tag_name) 35 | ASSET_NAME_WITH_EXTENSION=$(echo "$RELEASE_DATA" | jq -r '.assets[] | select(.name | startswith("hekate_ctcaer_")) | .name') 36 | ASSET_URL=$(echo "$RELEASE_DATA" | jq -r '.assets[] | select(.name | startswith("hekate_ctcaer_")) | .browser_download_url') 37 | 38 | # Download the zip file 39 | curl -L $ASSET_URL -o $ASSET_NAME_WITH_EXTENSION 40 | 41 | # Output the asset name without extension 42 | echo "original_asset_name=${ASSET_NAME_WITH_EXTENSION%.zip}" >> $GITHUB_ENV 43 | shell: bash 44 | 45 | - name: Replace nyx.bin and repackage 46 | run: | 47 | # Extract the zip file 48 | unzip "${original_asset_name}.zip" -d hekate_extracted 49 | 50 | # Replace nyx.bin with the one built 51 | cp output/nyx.bin hekate_extracted/bootloader/sys/nyx.bin 52 | 53 | # Define the new asset name 54 | echo "new_asset_name=${original_asset_name}_sc" >> $GITHUB_ENV 55 | shell: bash 56 | 57 | - name: Upload new zip as artifact 58 | uses: actions/upload-artifact@v4 59 | with: 60 | name: ${{ env.new_asset_name }} 61 | path: hekate_extracted/ 62 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | .vscode 3 | build/* 4 | output/* 5 | loader/payload_00.h 6 | loader/payload_01.h 7 | tools/bin2c/bin2c 8 | tools/bin2c/bin2c.exe 9 | tools/lz/lz77 10 | tools/lz/lz77.exe 11 | -------------------------------------------------------------------------------- /README_BOOTLOGO.md: -------------------------------------------------------------------------------- 1 | # hekate - Bootlogo 2 | 3 | The bootlogo can be any size with a maximum of 720 x 1280. 4 | 5 | When it's smaller than 720 x 1280, it is automatically centered and the background takes the color of the first pixel. 6 | 7 | The process is to create a landscape bootlogo and then rotate it 90 degrees counterclockwise. 8 | 9 | Lastly, the supported format is 32-bit (ARGB) BMP. Classic 24-bit (RGB) BMPs are not supported for performance reasons. 10 | 11 | 12 | ## How to configure 13 | 14 | If a boot entry specifies a custom logo path (`logopath=`), this one will be loaded. 15 | 16 | If the above is not found or the format is not correct, it will try to load `bootloader/bootlogo.bmp`. 17 | If this is not found, the default hekate logo will be used. 18 | 19 | (`bootloader/bootlogo.bmp` is basically like a global bootlogo.) 20 | -------------------------------------------------------------------------------- /Versions.inc: -------------------------------------------------------------------------------- 1 | # IPL Version. 2 | BLVERSION_MAJOR := 6 3 | BLVERSION_MINOR := 3 4 | BLVERSION_HOTFX := 1 5 | BLVERSION_REL := 0 6 | 7 | # Nyx Version. 8 | NYXVERSION_MAJOR := 1 9 | NYXVERSION_MINOR := 7 10 | NYXVERSION_HOTFX := 0 11 | NYXVERSION_REL := 0 12 | -------------------------------------------------------------------------------- /bdk/bdk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef BDK_H 18 | #define BDK_H 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | #include 74 | #include 75 | #include 76 | #include 77 | 78 | #include 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /bdk/display/vic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * VIC driver for Tegra X1 3 | * 4 | * Copyright (c) 2018-2019 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef _VIC_H_ 20 | #define _VIC_H_ 21 | 22 | #include 23 | 24 | #define VIC_THI_SLCG_OVERRIDE_LOW_A 0x8C 25 | 26 | typedef enum _vic_rotation_t 27 | { 28 | VIC_ROTATION_0 = 0, 29 | VIC_ROTATION_90 = 1, 30 | VIC_ROTATION_180 = 2, 31 | VIC_ROTATION_270 = 3, 32 | } vic_rotation_t; 33 | 34 | typedef enum _vic_pix_format_t 35 | { 36 | VIC_PIX_FORMAT_L8 = 1, // 8-bit LUT. 37 | VIC_PIX_FORMAT_X1B5G5R5 = 21, // 16-bit XBGR. 38 | VIC_PIX_FORMAT_B5G5R5X1 = 23, // 16-bit BGRX. 39 | 40 | VIC_PIX_FORMAT_A8B8G8R8 = 31, // 32-bit ABGR. 41 | VIC_PIX_FORMAT_A8R8G8B8 = 32, // 32-bit ARGB. 42 | VIC_PIX_FORMAT_B8G8R8A8 = 33, // 32-bit BGRA. 43 | VIC_PIX_FORMAT_R8G8B8A8 = 34, // 32-bit RGBA. 44 | 45 | VIC_PIX_FORMAT_X8B8G8R8 = 35, // 32-bit XBGR. 46 | VIC_PIX_FORMAT_X8R8G8B8 = 36, // 32-bit XRGB. 47 | VIC_PIX_FORMAT_B8G8R8X8 = 37, // 32-bit BGRX. 48 | VIC_PIX_FORMAT_R8G8B8X8 = 38, // 32-bit RGBX. 49 | } vic_pix_format_t; 50 | 51 | typedef struct _vic_surface_t 52 | { 53 | u32 src_buf; 54 | u32 dst_buf; 55 | u32 width; 56 | u32 height; 57 | u32 pix_fmt; 58 | u32 rotation; 59 | } vic_surface_t; 60 | 61 | void vic_set_surface(const vic_surface_t *sfc); 62 | int vic_compose(); 63 | int vic_init(); 64 | void vic_end(); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /bdk/fatfs_cfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _FATFS_CFG_H_ 18 | #define _FATFS_CFG_H_ 19 | 20 | // define FFCFG_INC in a project to use a specific FatFS configuration. 21 | // Example: FFCFG_INC := '"../$(PROJECT_DIR)/libs/fatfs/ffconf.h"' 22 | #ifdef FFCFG_INC 23 | #include FFCFG_INC 24 | #else 25 | #include "fatfs_conf.h" 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /bdk/gfx_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _GFX_UTILS_H_ 18 | #define _GFX_UTILS_H_ 19 | 20 | #ifdef GFX_INC 21 | #include GFX_INC 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /bdk/ianos/elfload/elfarch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2014, Owen Shepherd 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 9 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 11 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 13 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14 | * PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef ELFARCH_H 18 | #define ELFARCH_H 19 | 20 | #if defined(__i386__) 21 | #define EM_THIS EM_386 22 | #define EL_ARCH_USES_REL 23 | #elif defined(__amd64__) 24 | #define EM_THIS EM_AMD64 25 | #define EL_ARCH_USES_RELA 26 | #elif defined(__arm__) 27 | #define EM_THIS EM_ARM 28 | #define EL_ARCH_USES_REL 29 | #elif defined(__aarch64__) 30 | #define EM_THIS EM_AARCH64 31 | #define EL_ARCH_USES_RELA 32 | #define EL_ARCH_USES_REL 33 | #else 34 | #error specify your ELF architecture 35 | #endif 36 | 37 | #if defined(__LP64__) || defined(__LLP64__) 38 | #define ELFSIZE 64 39 | #else 40 | #define ELFSIZE 32 41 | #endif 42 | 43 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 44 | #define ELFDATATHIS ELFDATA2LSB 45 | #else 46 | #define ELFDATATHIS ELFDATA2MSB 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /bdk/ianos/elfload/elfreloc_aarch64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2014, Owen Shepherd 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 9 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 11 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 13 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14 | * PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #include "elfload.h" 18 | 19 | #if defined(__aarch64__) 20 | 21 | #define R_AARCH64_NONE 0 22 | #define R_AARCH64_RELATIVE 1027 23 | 24 | el_status el_applyrela(el_ctx *ctx, Elf_RelA *rel) 25 | { 26 | uptr *p = (uptr *)(rel->r_offset + ctx->base_load_paddr); 27 | u32 type = ELF_R_TYPE(rel->r_info); 28 | u32 sym = ELF_R_SYM(rel->r_info); 29 | 30 | switch (type) 31 | { 32 | case R_AARCH64_NONE: 33 | EL_DEBUG("R_AARCH64_NONE\n"); 34 | break; 35 | case R_AARCH64_RELATIVE: 36 | if (sym) 37 | { 38 | EL_DEBUG("R_AARCH64_RELATIVE with symbol ref!\n"); 39 | return EL_BADREL; 40 | } 41 | 42 | EL_DEBUG("Applying R_AARCH64_RELATIVE reloc @%p\n", p); 43 | *p = rel->r_addend + ctx->base_load_vaddr; 44 | break; 45 | 46 | default: 47 | EL_DEBUG("Bad relocation %u\n", type); 48 | return EL_BADREL; 49 | } 50 | 51 | return EL_OK; 52 | } 53 | 54 | el_status el_applyrel(el_ctx *ctx, Elf_Rel *rel) 55 | { 56 | uptr *p = (uptr *)(rel->r_offset + ctx->base_load_paddr); 57 | u32 type = ELF_R_TYPE(rel->r_info); 58 | u32 sym = ELF_R_SYM(rel->r_info); 59 | 60 | switch (type) 61 | { 62 | case R_AARCH64_NONE: 63 | EL_DEBUG("R_AARCH64_NONE\n"); 64 | break; 65 | case R_AARCH64_RELATIVE: 66 | if (sym) 67 | { 68 | EL_DEBUG("R_AARCH64_RELATIVE with symbol ref!\n"); 69 | return EL_BADREL; 70 | } 71 | 72 | EL_DEBUG("Applying R_AARCH64_RELATIVE reloc @%p\n", p); 73 | *p += ctx->base_load_vaddr; 74 | break; 75 | 76 | default: 77 | EL_DEBUG("Bad relocation %u\n", type); 78 | return EL_BADREL; 79 | } 80 | 81 | return EL_OK; 82 | } 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /bdk/ianos/elfload/elfreloc_arm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ---------------------------------------------------------------------------- 3 | * "THE BEER-WARE LICENSE" (Revision 42): 4 | * wrote this file. As long as you retain this notice you can do 5 | * whatever you want with this stuff. If we meet some day, and you think this 6 | * stuff is worth it, you can buy me a beer in return. M4xw 7 | * ---------------------------------------------------------------------------- 8 | */ 9 | 10 | #include "elfload.h" 11 | 12 | #if defined(__arm__) 13 | 14 | // Taken from http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044f/IHI0044F_aaelf.pdf 15 | #define R_ARM_NONE 0 16 | #define R_ARM_ABS32 2 17 | #define R_ARM_JUMP_SLOT 22 18 | #define R_ARM_GLOB_DAT 21 19 | #define R_ARM_RELATIVE 23 20 | 21 | el_status el_applyrel(el_ctx *ctx, Elf_Rel *rel) 22 | { 23 | u32 sym = ELF_R_SYM(rel->r_info); // Symbol offset 24 | u32 type = ELF_R_TYPE(rel->r_info); // Relocation Type 25 | uptr *p = (uptr *)(rel->r_offset + ctx->base_load_paddr); // Target Addr 26 | 27 | #if 0 // For later symbol usage 28 | Elf32_Sym *elfSym; 29 | const char *symbolName; 30 | 31 | // We resolve relocs from the originating elf-image 32 | elfSym = (Elf32_Sym *)(ctx->symtab.sh_offset + (char *)buffteg) + sym; 33 | int strtab_offset = ctx->shstr.sh_offset; 34 | char *strtab = (char *)buffteg + strtab_offset; 35 | symbolName = strtab + elfSym->st_name; 36 | //EL_DEBUG("Str: %s sz: %x val: %x\n", symbolName, elfSym->st_size, elfSym->st_value); 37 | #endif 38 | 39 | switch (type) 40 | { 41 | case R_ARM_NONE: 42 | EL_DEBUG("R_ARM_NONE\n"); 43 | break; 44 | case R_ARM_JUMP_SLOT: 45 | case R_ARM_ABS32: 46 | case R_ARM_GLOB_DAT: 47 | // Stubbed for later purpose 48 | //*p += elfSym->st_value; // + vaddr from sec 49 | //*p |= 0; // 1 if Thumb && STT_FUNC, ignored for now 50 | break; 51 | case R_ARM_RELATIVE: // Needed for PIE 52 | if (sym) 53 | { 54 | return EL_BADREL; 55 | } 56 | *p += ctx->base_load_vaddr; 57 | break; 58 | 59 | default: 60 | return EL_BADREL; 61 | } 62 | 63 | return EL_OK; 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /bdk/ianos/ianos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 M4xw 3 | * Copyright (c) 2018 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef IANOS_H 19 | #define IANOS_H 20 | 21 | #include 22 | 23 | typedef enum 24 | { 25 | DRAM_LIB = 0, // DRAM library. 26 | EXEC_ELF = 1, // Executable elf that does not return. 27 | DR64_LIB = 2, // AARCH64 DRAM library. 28 | AR64_ELF = 3, // Executable elf that does not return. 29 | KEEP_IN_RAM = (1 << 31) // Shared library mask. 30 | } elfType_t; 31 | 32 | uintptr_t ianos_loader(char *path, elfType_t type, void* config); 33 | 34 | #endif -------------------------------------------------------------------------------- /bdk/input/als.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ambient light sensor driver for Nintendo Switch's Rohm BH1730 3 | * 4 | * Copyright (c) 2018 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef __ALS_H_ 20 | #define __ALS_H_ 21 | 22 | #include 23 | 24 | #define BH1730_I2C_ADDR 0x29 25 | 26 | #define BH1730_CMD_MAGIC 0x80 27 | #define BH1730_CMD_SETADDR 0x00 28 | #define BH1730_CMD_SPECCMD 0x60 29 | #define BH1730_SPECCMD_RESET 0x4 30 | 31 | #define BH1730_CONTROL_REG 0x00 32 | #define BH1730_CTL_ADC_VALID 0x10 33 | #define BH1730_CTL_ONE_TIME 0x08 34 | #define BH1730_CTL_DAT0_ONLY 0x04 35 | #define BH1730_CTL_ADC_EN 0x02 36 | #define BH1730_CTL_POWER_ON 0x01 37 | #define BH1730_TIMING_REG 0x01 38 | #define BH1730_GAIN_REG 0x07 39 | #define BH1730_GAIN_1X 0x00 40 | #define BH1730_GAIN_2X 0x01 41 | #define BH1730_GAIN_64X 0x02 42 | #define BH1730_GAIN_128X 0x03 43 | #define BH1730_DATA0LOW_REG 0x14 44 | #define BH1730_DATA0HIGH_REG 0x15 45 | #define BH1730_DATA1LOW_REG 0x16 46 | #define BH1730_DATA1HIGH_REG 0x17 47 | 48 | #define BH1730_ADDR(reg) (BH1730_CMD_MAGIC | BH1730_CMD_SETADDR | (reg)) 49 | #define BH1730_SPEC(cmd) (BH1730_CMD_MAGIC | BH1730_CMD_SPECCMD | (cmd)) 50 | 51 | typedef struct _als_ctxt_t 52 | { 53 | u32 lux; 54 | bool over_limit; 55 | u32 vi_light; 56 | u32 ir_light; 57 | u8 gain; 58 | u8 cycle; 59 | } als_ctxt_t; 60 | 61 | void set_als_cfg(als_ctxt_t *als_ctxt, u8 gain, u8 cycle); 62 | void get_als_lux(als_ctxt_t *als_ctxt); 63 | u8 als_power_on(als_ctxt_t *als_ctxt); 64 | 65 | #endif /* __ALS_H_ */ 66 | -------------------------------------------------------------------------------- /bdk/input/joycon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ambient light sensor driver for Nintendo Switch's Rohm BH1730 3 | * 4 | * Copyright (c) 2018 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef __JOYCON_H_ 20 | #define __JOYCON_H_ 21 | 22 | #include 23 | 24 | #define JC_BTNS_DIRECTION_PAD 0xF0000 25 | #define JC_BTNS_PREV_NEXT 0x800080 26 | #define JC_BTNS_ENTER 0x400008 27 | #define JC_BTNS_ESC 0x4 28 | 29 | #define JC_BTNS_ALL (JC_BTNS_PREV_NEXT | JC_BTNS_ENTER | JC_BTNS_DIRECTION_PAD | JC_BTNS_ESC) 30 | 31 | typedef struct _jc_bt_conn_t 32 | { 33 | u8 type; 34 | u8 mac[6]; 35 | u8 host_mac[6]; 36 | u8 ltk[16]; 37 | } jc_bt_conn_t; 38 | 39 | typedef struct _jc_gamepad_rpt_t 40 | { 41 | union 42 | { 43 | struct 44 | { 45 | // Joy-Con (R). 46 | /*00*/ u32 y:1; 47 | /*01*/ u32 x:1; 48 | /*02*/ u32 b:1; 49 | /*03*/ u32 a:1; 50 | /*04*/ u32 sr_r:1; 51 | /*05*/ u32 sl_r:1; 52 | /*06*/ u32 r:1; 53 | /*07*/ u32 zr:1; 54 | 55 | // Shared 56 | /*08*/ u32 minus:1; 57 | /*09*/ u32 plus:1; 58 | /*10*/ u32 r3:1; 59 | /*11*/ u32 l3:1; 60 | /*12*/ u32 home:1; 61 | /*13*/ u32 cap:1; 62 | /*14*/ u32 pad:1; 63 | /*15*/ u32 wired:1; 64 | 65 | // Joy-Con (L). 66 | /*16*/ u32 down:1; 67 | /*17*/ u32 up:1; 68 | /*18*/ u32 right:1; 69 | /*19*/ u32 left:1; 70 | /*20*/ u32 sr_l:1; 71 | /*21*/ u32 sl_l:1; 72 | /*22*/ u32 l:1; 73 | /*23*/ u32 zl:1; 74 | }; 75 | u32 buttons; 76 | }; 77 | 78 | u16 lstick_x; 79 | u16 lstick_y; 80 | u16 rstick_x; 81 | u16 rstick_y; 82 | bool center_stick_l; 83 | bool center_stick_r; 84 | bool conn_l; 85 | bool conn_r; 86 | bool sio_mode; 87 | u8 batt_info_l; // Also Sio Connected status. 88 | u8 batt_info_r; // Also Sio IRQ. 89 | jc_bt_conn_t bt_conn_l; 90 | jc_bt_conn_t bt_conn_r; 91 | } jc_gamepad_rpt_t; 92 | 93 | typedef struct _jc_calib_t 94 | { 95 | u16 x_max:12; 96 | u16 y_max:12; 97 | u16 x_center:12; 98 | u16 y_center:12; 99 | u16 x_min:12; 100 | u16 y_min:12; 101 | } __attribute__((packed)) jc_calib_t; 102 | 103 | void jc_init_hw(); 104 | void jc_deinit(); 105 | jc_gamepad_rpt_t *joycon_poll(); 106 | jc_gamepad_rpt_t *jc_get_bt_pairing_info(bool *is_l_hos, bool *is_r_hos); 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /bdk/libs/compr/blz.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 rajkosto 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _BLZ_H_ 18 | #define _BLZ_H_ 19 | 20 | #include 21 | 22 | typedef struct _blz_footer 23 | { 24 | u32 cmp_and_hdr_size; 25 | u32 header_size; 26 | u32 addl_size; 27 | } blz_footer; 28 | 29 | // Returns pointer to footer in comp_data if present, additionally copies it to out_footer if not NULL. 30 | const blz_footer *blz_get_footer(const u8 *comp_data, u32 comp_data_size, blz_footer *out_footer); 31 | // Returns 0 on failure. 32 | int blz_uncompress_inplace(u8 *data, u32 comp_size, const blz_footer *footer); 33 | // Returns 0 on failure. 34 | int blz_uncompress_srcdest(const u8 *comp_data, u32 comp_data_size, u8 *dst_data, u32 dst_size); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /bdk/libs/compr/lz.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Name: lz.h 3 | * Author: Marcus Geelnard 4 | * Description: LZ77 coder/decoder interface. 5 | * Reentrant: Yes 6 | *------------------------------------------------------------------------- 7 | * Copyright (c) 2003-2006 Marcus Geelnard 8 | * 9 | * This software is provided 'as-is', without any express or implied 10 | * warranty. In no event will the authors be held liable for any damages 11 | * arising from the use of this software. 12 | * 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 17 | * 1. The origin of this software must not be misrepresented; you must not 18 | * claim that you wrote the original software. If you use this software 19 | * in a product, an acknowledgment in the product documentation would 20 | * be appreciated but is not required. 21 | * 22 | * 2. Altered source versions must be plainly marked as such, and must not 23 | * be misrepresented as being the original software. 24 | * 25 | * 3. This notice may not be removed or altered from any source 26 | * distribution. 27 | * 28 | * Marcus Geelnard 29 | * marcus.geelnard at home.se 30 | *************************************************************************/ 31 | 32 | #ifndef _lz_h_ 33 | #define _lz_h_ 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | 40 | /************************************************************************* 41 | * Function prototypes 42 | *************************************************************************/ 43 | 44 | unsigned int LZ_Uncompress( const unsigned char *in, unsigned char *out, 45 | unsigned int insize ); 46 | 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* _lz_h_ */ 53 | -------------------------------------------------------------------------------- /bdk/libs/fatfs/ffsystem.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /* Sample Code of OS Dependent Functions for FatFs */ 3 | /* (C) ChaN, 2018 */ 4 | /* (C) CTCaer, 2018-2024 */ 5 | /*------------------------------------------------------------------------*/ 6 | 7 | #include 8 | 9 | #include 10 | 11 | #if FF_USE_LFN == 3 /* Dynamic memory allocation */ 12 | 13 | /*------------------------------------------------------------------------*/ 14 | /* Allocate a memory block */ 15 | /*------------------------------------------------------------------------*/ 16 | 17 | void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */ 18 | UINT msize /* Number of bytes to allocate */ 19 | ) 20 | { 21 | // Ensure size is aligned to SDMMC block size. 22 | return malloc(ALIGN(msize, SDMMC_DAT_BLOCKSIZE)); /* Allocate a new memory block with POSIX API */ 23 | } 24 | 25 | 26 | /*------------------------------------------------------------------------*/ 27 | /* Free a memory block */ 28 | /*------------------------------------------------------------------------*/ 29 | 30 | void ff_memfree ( 31 | void* mblock /* Pointer to the memory block to free (nothing to do if null) */ 32 | ) 33 | { 34 | free(mblock); /* Free the memory block with POSIX API */ 35 | } 36 | 37 | #endif 38 | 39 | #if FF_FS_NORTC == 0 40 | 41 | /*------------------------------------------------------------------------*/ 42 | /* Get real time clock */ 43 | /*------------------------------------------------------------------------*/ 44 | 45 | DWORD get_fattime ( 46 | void 47 | ) 48 | { 49 | rtc_time_t time; 50 | 51 | max77620_rtc_get_time_adjusted(&time); 52 | 53 | return (((DWORD)(time.year - 1980) << 25) | ((DWORD)time.month << 21) | ((DWORD)time.day << 16) | 54 | ((DWORD)time.hour << 11) | ((DWORD)time.min << 5) | (time.sec >> 1)); 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/docs/astyle_c: -------------------------------------------------------------------------------- 1 | --style=kr --convert-tabs --indent=spaces=4 --indent-switches --pad-oper --unpad-paren --align-pointer=middle --suffix=.bak --lineend=linux --min-conditional-indent= 2 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/docs/astyle_h: -------------------------------------------------------------------------------- 1 | --convert-tabs --indent=spaces=4 2 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/licence.txt: -------------------------------------------------------------------------------- 1 | MIT licence 2 | Copyright (c) 2016 Gábor Kiss-Vámosi 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_core/lv_core.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_group.c 2 | CSRCS += lv_indev.c 3 | CSRCS += lv_obj.c 4 | CSRCS += lv_refr.c 5 | CSRCS += lv_style.c 6 | CSRCS += lv_vdb.c 7 | CSRCS += lv_lang.c 8 | 9 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_core 10 | VPATH += :$(LVGL_DIR)/lvgl/lv_core 11 | 12 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_core" 13 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_core/lv_lang.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_lang.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LANG_H 7 | #define LV_LANG_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_MULTI_LANG 23 | 24 | #include 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | #define LV_LANG_TXT_ID_NONE 0xFFFF /*Used to not assign any text IDs for a multi-language object.*/ 30 | 31 | /********************** 32 | * TYPEDEFS 33 | **********************/ 34 | 35 | /********************** 36 | * GLOBAL PROTOTYPES 37 | **********************/ 38 | 39 | /** 40 | * Change the language 41 | * @param lang_id the id of the 42 | */ 43 | void lv_lang_set(uint8_t lang_id); 44 | 45 | /** 46 | * Set a function to get the texts of the set languages from a `txt_id` 47 | * @param fp a function pointer to get the texts 48 | */ 49 | void lv_lang_set_text_func(const void * (*fp)(uint16_t)); 50 | 51 | /** 52 | * Use the function set by `lv_lang_set_text_func` to get the `txt_id` text in the set language 53 | * @param txt_id an ID of the text to get 54 | * @return the `txt_id` txt on the set language 55 | */ 56 | const void * lv_lang_get_text(uint16_t txt_id); 57 | 58 | /** 59 | * Return with ID of the currently selected language 60 | * @return pointer to the active screen object (loaded by 'lv_scr_load()') 61 | */ 62 | uint8_t lv_lang_act(void); 63 | 64 | /********************** 65 | * MACROS 66 | **********************/ 67 | 68 | #endif /*USE_LV_MULTI_LANG*/ 69 | 70 | #ifdef __cplusplus 71 | } /* extern "C" */ 72 | #endif 73 | 74 | #endif /*LV_LANG_H*/ 75 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_core/lv_refr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_refr.h 3 | * 4 | */ 5 | 6 | #ifndef LV_REFR_H 7 | #define LV_REFR_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_obj.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * STATIC PROTOTYPES 28 | **********************/ 29 | 30 | /********************** 31 | * STATIC VARIABLES 32 | **********************/ 33 | 34 | /********************** 35 | * MACROS 36 | **********************/ 37 | 38 | /********************** 39 | * GLOBAL FUNCTIONS 40 | **********************/ 41 | 42 | /** 43 | * Initialize the screen refresh subsystem 44 | */ 45 | void lv_refr_init(void); 46 | 47 | /** 48 | * Redraw the invalidated areas now. 49 | * Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process can 50 | * prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process (e.g. progress bar) 51 | * this function can be called when the screen should be updated. 52 | */ 53 | void lv_refr_now(void); 54 | 55 | /** 56 | * Invalidate an area 57 | * @param area_p pointer to area which should be invalidated 58 | */ 59 | void lv_inv_area(const lv_area_t * area_p); 60 | 61 | /** 62 | * Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels 63 | * @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num)) 64 | */ 65 | void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t)); 66 | 67 | /** 68 | * Called when an area is invalidated to modify the coordinates of the area. 69 | * Special display controllers may require special coordinate rounding 70 | * @param cb pointer to the a function which will modify the area 71 | */ 72 | void lv_refr_set_round_cb(void(*cb)(lv_area_t*)); 73 | 74 | /** 75 | * Get the number of areas in the buffer 76 | * @return number of invalid areas 77 | */ 78 | uint16_t lv_refr_get_buf_size(void); 79 | 80 | /** 81 | * Pop (delete) the last 'num' invalidated areas from the buffer 82 | * @param num number of areas to delete 83 | */ 84 | void lv_refr_pop_from_buf(uint16_t num); 85 | /********************** 86 | * STATIC FUNCTIONS 87 | **********************/ 88 | 89 | 90 | #ifdef __cplusplus 91 | } /* extern "C" */ 92 | #endif 93 | 94 | #endif /*LV_REFR_H*/ 95 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_draw/lv_draw.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_draw_vbasic.c 2 | CSRCS += lv_draw_rbasic.c 3 | CSRCS += lv_draw.c 4 | CSRCS += lv_draw_rect.c 5 | CSRCS += lv_draw_label.c 6 | CSRCS += lv_draw_line.c 7 | CSRCS += lv_draw_img.c 8 | CSRCS += lv_draw_arc.c 9 | CSRCS += lv_draw_triangle.c 10 | 11 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_draw 12 | VPATH += :$(LVGL_DIR)/lvgl/lv_draw 13 | 14 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_draw" 15 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_draw/lv_draw_arc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_arc.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_ARC_H 7 | #define LV_DRAW_ARC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Draw an arc. (Can draw pie too with great thickness.) 32 | * @param center_x the x coordinate of the center of the arc 33 | * @param center_y the y coordinate of the center of the arc 34 | * @param radius the radius of the arc 35 | * @param mask the arc will be drawn only in this mask 36 | * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right) 37 | * @param end_angle the end angle of the arc 38 | * @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used) 39 | * @param opa_scale scale down all opacities by the factor 40 | */ 41 | void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask, 42 | uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale); 43 | 44 | /********************** 45 | * MACROS 46 | **********************/ 47 | 48 | 49 | #ifdef __cplusplus 50 | } /* extern "C" */ 51 | #endif 52 | 53 | #endif /*LV_DRAW_ARC*/ 54 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_draw/lv_draw_label.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_label.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_LABEL_H 7 | #define LV_DRAW_LABEL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Write a text 32 | * @param coords coordinates of the label 33 | * @param mask the label will be drawn only in this area 34 | * @param style pointer to a style 35 | * @param opa_scale scale down all opacities by the factor 36 | * @param txt 0 terminated text to write 37 | * @param flag settings for the text from 'txt_flag_t' enum 38 | * @param offset text offset in x and y direction (NULL if unused) 39 | * 40 | */ 41 | void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale, 42 | const char * txt, lv_txt_flag_t flag, lv_point_t * offset); 43 | 44 | /********************** 45 | * MACROS 46 | **********************/ 47 | 48 | 49 | #ifdef __cplusplus 50 | } /* extern "C" */ 51 | #endif 52 | 53 | #endif /*LV_DRAW_LABEL_H*/ 54 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_draw/lv_draw_line.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_line.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_LINE_H 7 | #define LV_DRAW_LINE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | 29 | /** 30 | * Draw a line 31 | * @param point1 first point of the line 32 | * @param point2 second point of the line 33 | * @param mask the line will be drawn only on this area 34 | * @param style pointer to a line's style 35 | * @param opa_scale scale down all opacities by the factor 36 | */ 37 | void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask, 38 | const lv_style_t * style, lv_opa_t opa_scale); 39 | 40 | /********************** 41 | * MACROS 42 | **********************/ 43 | 44 | 45 | #ifdef __cplusplus 46 | } /* extern "C" */ 47 | #endif 48 | 49 | #endif /*LV_DRAW_LINE_H*/ 50 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_draw/lv_draw_rect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_rect.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_RECT_H 7 | #define LV_DRAW_RECT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Draw a rectangle 32 | * @param coords the coordinates of the rectangle 33 | * @param mask the rectangle will be drawn only in this mask 34 | * @param style pointer to a style 35 | * @param opa_scale scale down all opacities by the factor 36 | */ 37 | void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); 38 | 39 | /********************** 40 | * MACROS 41 | **********************/ 42 | 43 | 44 | #ifdef __cplusplus 45 | } /* extern "C" */ 46 | #endif 47 | 48 | #endif /*LV_DRAW_RECT_H*/ 49 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_draw/lv_draw_triangle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_triangle.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_TRIANGLE_H 7 | #define LV_DRAW_TRIANGLE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | /*Experimental use for 3D modeling*/ 30 | #define USE_LV_TRIANGLE 1 31 | 32 | #if USE_LV_TRIANGLE != 0 33 | /** 34 | * 35 | * @param points pointer to an array with 3 points 36 | * @param mask the triangle will be drawn only in this mask 37 | * @param color color of the triangle 38 | */ 39 | void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_color_t color); 40 | #endif 41 | 42 | /********************** 43 | * MACROS 44 | **********************/ 45 | 46 | 47 | #ifdef __cplusplus 48 | } /* extern "C" */ 49 | #endif 50 | 51 | #endif /*LV_DRAW_TRIANGLE_H*/ 52 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_draw/lv_draw_vbasic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_vbasic.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_VBASIC_H 7 | #define LV_DRAW_VBASIC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_VDB_SIZE != 0 23 | 24 | #include "../lv_misc/lv_color.h" 25 | #include "../lv_misc/lv_area.h" 26 | #include "../lv_misc/lv_font.h" 27 | 28 | /********************* 29 | * DEFINES 30 | *********************/ 31 | 32 | /********************** 33 | * TYPEDEFS 34 | **********************/ 35 | 36 | /********************** 37 | * GLOBAL PROTOTYPES 38 | **********************/ 39 | 40 | void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa); 41 | /** 42 | * Fill an area in the Virtual Display Buffer 43 | * @param cords_p coordinates of the area to fill 44 | * @param mask_p fill only o this mask 45 | * @param color fill color 46 | * @param opa opacity of the area (0..255) 47 | */ 48 | void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, 49 | lv_color_t color, lv_opa_t opa); 50 | 51 | /** 52 | * Draw a letter in the Virtual Display Buffer 53 | * @param pos_p left-top coordinate of the latter 54 | * @param mask_p the letter will be drawn only on this area 55 | * @param font_p pointer to font 56 | * @param letter a letter to draw 57 | * @param color color of letter 58 | * @param opa opacity of letter (0..255) 59 | */ 60 | void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p, 61 | const lv_font_t * font_p, uint32_t letter, 62 | lv_color_t color, lv_opa_t opa); 63 | 64 | /** 65 | * Draw a color map to the display (image) 66 | * @param cords_p coordinates the color map 67 | * @param mask_p the map will drawn only on this area (truncated to VDB area) 68 | * @param map_p pointer to a lv_color_t array 69 | * @param opa opacity of the map 70 | * @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels 71 | * @param alpha_byte true: extra alpha byte is inserted for every pixel 72 | * @param recolor mix the pixels with this color 73 | * @param recolor_opa the intense of recoloring 74 | */ 75 | void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, 76 | const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte, 77 | lv_color_t recolor, lv_opa_t recolor_opa); 78 | 79 | /********************** 80 | * MACROS 81 | **********************/ 82 | 83 | #endif /*LV_VDB_SIZE != 0*/ 84 | 85 | #ifdef __cplusplus 86 | } /* extern "C" */ 87 | #endif 88 | 89 | #endif /*LV_DRAW_RBASIC_H*/ 90 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_fonts/hekate_symbol_120.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "../lv_misc/lv_font.h" 18 | 19 | #include 20 | 21 | #if USE_HEKATE_SYMBOL_120 != 0 /*Can be enabled in lv_conf.h*/ 22 | 23 | /*********************************************************************************** 24 | * hekate-symbols-huge.ttf 120 px Font in U+f002 () .. U+f007 () range with all bpp 25 | * Sparse font with only these characters:  26 | ***********************************************************************************/ 27 | 28 | /*Store the glyph descriptions*/ 29 | static const lv_font_glyph_dsc_t hekate_symbol_120_glyph_dsc[] = 30 | { 31 | #if USE_HEKATE_SYMBOL_120 == 8 32 | {.w_px = 103, .glyph_index = 0}, /*Unicode: U+f002 ()*/ 33 | {.w_px = 103, .glyph_index = 12360}, /*Unicode: U+f003 ()*/ 34 | {.w_px = 103, .glyph_index = 24720}, /*Unicode: U+f005 ()*/ 35 | {.w_px = 103, .glyph_index = 37080}, /*Unicode: U+f007 ()*/ 36 | 37 | #endif 38 | }; 39 | 40 | lv_font_t hekate_symbol_120 = 41 | { 42 | .unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/ 43 | .unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/ 44 | .h_px = 120, /*Font height in pixels*/ 45 | .glyph_bitmap = (const uint8_t *)(NYX_RES_ADDR + 0x36E00), /*Bitmap of glyphs*/ 46 | .glyph_dsc = hekate_symbol_120_glyph_dsc, /*Description of glyphs*/ 47 | .glyph_cnt = 4, /*Number of glyphs in the font*/ 48 | .unicode_list = NULL, /*List of unicode characters*/ 49 | .get_bitmap = lv_font_get_bitmap_continuous, /*Function pointer to get glyph's bitmap*/ 50 | .get_width = lv_font_get_width_continuous, /*Function pointer to get glyph's width*/ 51 | #if USE_HEKATE_SYMBOL_120 == 8 52 | .bpp = 8, /*Bit per pixel*/ 53 | #endif 54 | .monospace = 0, /*Fix width (0: if not used)*/ 55 | .next_page = NULL, /*Pointer to a font extension*/ 56 | }; 57 | 58 | #endif /*USE_HEKATE_SYMBOL_100*/ 59 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_fonts/lv_font_builtin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | /** 18 | * @file lv_font_built_in.c 19 | * 20 | */ 21 | 22 | /********************* 23 | * INCLUDES 24 | *********************/ 25 | #include "lv_font_builtin.h" 26 | 27 | /********************* 28 | * DEFINES 29 | *********************/ 30 | 31 | /********************** 32 | * TYPEDEFS 33 | **********************/ 34 | 35 | /********************** 36 | * STATIC PROTOTYPES 37 | **********************/ 38 | 39 | /********************** 40 | * STATIC VARIABLES 41 | **********************/ 42 | 43 | /********************** 44 | * MACROS 45 | **********************/ 46 | 47 | /********************** 48 | * GLOBAL FUNCTIONS 49 | **********************/ 50 | 51 | /** 52 | * Initialize the built-in fonts 53 | */ 54 | void lv_font_builtin_init(void) 55 | { 56 | /*InterUI 20*/ 57 | #if USE_INTERUI_20 != 0 58 | lv_font_add(&interui_20, NULL); 59 | lv_font_add(&harmony_os_sans_20, NULL); 60 | #endif 61 | 62 | /*SYMBOL 20*/ 63 | #if USE_HEKATE_SYMBOL_20 != 0 64 | #if USE_INTERUI_20 != 0 65 | lv_font_add(&hekate_symbol_20, &interui_20); 66 | lv_font_add(&hekate_symbol_20, &harmony_os_sans_20); 67 | #else 68 | lv_font_add(&hekate_symbol_20, NULL); 69 | #endif 70 | #endif 71 | 72 | /*InterUI 30*/ 73 | #if USE_INTERUI_30 != 0 74 | lv_font_add(&interui_30, NULL); 75 | lv_font_add(&harmony_os_sans_30, NULL); 76 | #endif 77 | 78 | /*SYMBOL 30*/ 79 | #if USE_HEKATE_SYMBOL_30 != 0 80 | #if USE_INTERUI_30 != 0 81 | lv_font_add(&hekate_symbol_30, &interui_30); 82 | lv_font_add(&hekate_symbol_30, &harmony_os_sans_30); 83 | #else 84 | lv_font_add(&hekate_symbol_30, NULL); 85 | #endif 86 | #endif 87 | 88 | /*MONO 12*/ 89 | #if USE_UBUNTU_MONO != 0 90 | lv_font_add(&ubuntu_mono, NULL); 91 | #if USE_INTERUI_20 != 0 92 | lv_font_add(&hekate_symbol_20, &ubuntu_mono); 93 | #endif 94 | #endif 95 | 96 | /*Symbol 120*/ 97 | #if USE_HEKATE_SYMBOL_120 != 0 98 | lv_font_add(&hekate_symbol_120, NULL); 99 | #endif 100 | } 101 | 102 | /********************** 103 | * STATIC FUNCTIONS 104 | **********************/ 105 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_fonts/lv_font_builtin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | /** 18 | * @file lv_font_builtin.h 19 | * 20 | */ 21 | 22 | #ifndef LV_FONT_BUILTIN_H 23 | #define LV_FONT_BUILTIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /********************* 30 | * INCLUDES 31 | *********************/ 32 | #ifdef LV_CONF_INCLUDE_SIMPLE 33 | #include "lv_conf.h" 34 | #else 35 | #include "../../lv_conf.h" 36 | #endif 37 | 38 | #include "../lv_misc/lv_font.h" 39 | 40 | /********************* 41 | * DEFINES 42 | *********************/ 43 | 44 | /********************** 45 | * TYPEDEFS 46 | **********************/ 47 | 48 | /********************** 49 | * GLOBAL PROTOTYPES 50 | **********************/ 51 | 52 | /** 53 | * Initialize the built-in fonts 54 | */ 55 | void lv_font_builtin_init(void); 56 | 57 | /********************** 58 | * MACROS 59 | **********************/ 60 | 61 | /********************** 62 | * FONT DECLARATIONS 63 | **********************/ 64 | 65 | /*20 px */ 66 | #if USE_INTERUI_20 67 | LV_FONT_DECLARE(interui_20); 68 | #endif 69 | 70 | #if USE_HEKATE_SYMBOL_20 71 | LV_FONT_DECLARE(hekate_symbol_20); 72 | #endif 73 | 74 | /*30 px */ 75 | #if USE_INTERUI_30 76 | LV_FONT_DECLARE(interui_30); 77 | #endif 78 | 79 | #if USE_HEKATE_SYMBOL_30 80 | LV_FONT_DECLARE(hekate_symbol_30); 81 | #endif 82 | 83 | #if USE_UBUNTU_MONO 84 | LV_FONT_DECLARE(ubuntu_mono); 85 | #endif 86 | 87 | #if USE_HEKATE_SYMBOL_120 88 | LV_FONT_DECLARE(hekate_symbol_120); 89 | #endif 90 | 91 | #ifdef __cplusplus 92 | } /* extern "C" */ 93 | #endif 94 | 95 | #endif /*LV_FONT_BUILTIN_H*/ 96 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_fonts/lv_fonts.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_font_builtin.c 2 | CSRCS += hekate_symbol_10.c 3 | CSRCS += hekate_symbol_20.c 4 | CSRCS += hekate_symbol_30.c 5 | CSRCS += hekate_symbol_40.c 6 | CSRCS += interui_12.c 7 | CSRCS += interui_20.c 8 | CSRCS += interui_30.c 9 | CSRCS += interui_40.c 10 | 11 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_fonts 12 | VPATH += :$(LVGL_DIR)/lvgl/lv_fonts 13 | 14 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_fonts" 15 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_hal/lv_hal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal.h 3 | * 4 | */ 5 | 6 | #ifndef HAL_H 7 | #define HAL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_hal_disp.h" 17 | #include "lv_hal_indev.h" 18 | #include "lv_hal_tick.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | #ifdef __cplusplus 37 | } /* extern "C" */ 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_hal/lv_hal.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_hal_disp.c 2 | CSRCS += lv_hal_indev.c 3 | CSRCS += lv_hal_tick.c 4 | 5 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_hal 6 | VPATH += :$(LVGL_DIR)/lvgl/lv_hal 7 | 8 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_hal" 9 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_hal/lv_hal_tick.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file systick.c 3 | * Provide access to the system tick with 1 millisecond resolution 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #ifdef LV_CONF_INCLUDE_SIMPLE 10 | #include "lv_conf.h" 11 | #else 12 | #include "../../lv_conf.h" 13 | #endif 14 | 15 | #include "lv_hal_tick.h" 16 | #include 17 | 18 | #if LV_TICK_CUSTOM == 1 19 | #include LV_TICK_CUSTOM_INCLUDE 20 | #endif 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /********************** 31 | * STATIC PROTOTYPES 32 | **********************/ 33 | 34 | /********************** 35 | * STATIC VARIABLES 36 | **********************/ 37 | static uint32_t sys_time = 0; 38 | static volatile uint8_t tick_irq_flag; 39 | 40 | /********************** 41 | * MACROS 42 | **********************/ 43 | 44 | /********************** 45 | * GLOBAL FUNCTIONS 46 | **********************/ 47 | 48 | /** 49 | * You have to call this function periodically 50 | * @param tick_period the call period of this function in milliseconds 51 | */ 52 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period) 53 | { 54 | tick_irq_flag = 0; 55 | sys_time += tick_period; 56 | } 57 | 58 | /** 59 | * Get the elapsed milliseconds since start up 60 | * @return the elapsed milliseconds 61 | */ 62 | uint32_t lv_tick_get(void) 63 | { 64 | #if LV_TICK_CUSTOM == 0 65 | uint32_t result; 66 | do { 67 | tick_irq_flag = 1; 68 | result = sys_time; 69 | } while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt. Continue until make a non interrupted cycle */ 70 | 71 | return result; 72 | #else 73 | return LV_TICK_CUSTOM_SYS_TIME_EXPR; 74 | #endif 75 | } 76 | 77 | /** 78 | * Get the elapsed milliseconds since a previous time stamp 79 | * @param prev_tick a previous time stamp (return value of systick_get() ) 80 | * @return the elapsed milliseconds since 'prev_tick' 81 | */ 82 | uint32_t lv_tick_elaps(uint32_t prev_tick) 83 | { 84 | uint32_t act_time = lv_tick_get(); 85 | 86 | /*If there is no overflow in sys_time simple subtract*/ 87 | if(act_time >= prev_tick) { 88 | prev_tick = act_time - prev_tick; 89 | } else { 90 | prev_tick = UINT32_MAX - prev_tick + 1; 91 | prev_tick += act_time; 92 | } 93 | 94 | return prev_tick; 95 | } 96 | 97 | /********************** 98 | * STATIC FUNCTIONS 99 | **********************/ 100 | 101 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_hal/lv_hal_tick.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_hal_tick.h 3 | * Provide access to the system tick with 1 millisecond resolution 4 | */ 5 | 6 | #ifndef LV_HAL_TICK_H 7 | #define LV_HAL_TICK_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | #include 22 | 23 | /********************* 24 | * DEFINES 25 | *********************/ 26 | #ifndef LV_ATTRIBUTE_TICK_INC 27 | #define LV_ATTRIBUTE_TICK_INC 28 | #endif 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL PROTOTYPES 36 | **********************/ 37 | 38 | /** 39 | * You have to call this function periodically 40 | * @param tick_period the call period of this function in milliseconds 41 | */ 42 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period); 43 | 44 | /** 45 | * Get the elapsed milliseconds since start up 46 | * @return the elapsed milliseconds 47 | */ 48 | uint32_t lv_tick_get(void); 49 | 50 | /** 51 | * Get the elapsed milliseconds since a previous time stamp 52 | * @param prev_tick a previous time stamp (return value of systick_get() ) 53 | * @return the elapsed milliseconds since 'prev_tick' 54 | */ 55 | uint32_t lv_tick_elaps(uint32_t prev_tick); 56 | 57 | /********************** 58 | * MACROS 59 | **********************/ 60 | 61 | #ifdef __cplusplus 62 | } /* extern "C" */ 63 | #endif 64 | 65 | #endif /*LV_HAL_TICK_H*/ 66 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_circ.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_circ.c 3 | * Circle drawing algorithm (with Bresenham) 4 | * Only a 1/8 circle is calculated. Use CIRC_OCT1_X, CIRC_OCT1_Y macros to get 5 | * the other octets. 6 | */ 7 | 8 | /********************* 9 | * INCLUDES 10 | *********************/ 11 | #include "lv_circ.h" 12 | 13 | /********************* 14 | * DEFINES 15 | *********************/ 16 | 17 | /********************** 18 | * TYPEDEFS 19 | **********************/ 20 | 21 | /********************** 22 | * STATIC PROTOTYPES 23 | **********************/ 24 | 25 | /********************** 26 | * STATIC VARIABLES 27 | **********************/ 28 | 29 | /********************** 30 | * MACROS 31 | **********************/ 32 | 33 | /********************** 34 | * GLOBAL FUNCTIONS 35 | **********************/ 36 | 37 | /** 38 | * Initialize the circle drawing 39 | * @param c pointer to a point. The coordinates will be calculated here 40 | * @param tmp point to a variable. It will store temporary data 41 | * @param radius radius of the circle 42 | */ 43 | void lv_circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius) 44 | { 45 | c->x = radius; 46 | c->y = 0; 47 | *tmp = 1 - radius; 48 | } 49 | 50 | /** 51 | * Test the circle drawing is ready or not 52 | * @param c same as in circ_init 53 | * @return true if the circle is not ready yet 54 | */ 55 | bool lv_circ_cont(lv_point_t * c) 56 | { 57 | return c->y <= c->x ? true : false; 58 | } 59 | 60 | /** 61 | * Get the next point from the circle 62 | * @param c same as in circ_init. The next point stored here. 63 | * @param tmp same as in circ_init. 64 | */ 65 | void lv_circ_next(lv_point_t * c, lv_coord_t * tmp) 66 | { 67 | c->y++; 68 | 69 | if(*tmp <= 0) { 70 | (*tmp) += 2 * c->y + 1; // Change in decision criterion for y -> y+1 71 | } else { 72 | c->x--; 73 | (*tmp) += 2 * (c->y - c->x) + 1; // Change for y -> y+1, x -> x-1 74 | } 75 | } 76 | 77 | /********************** 78 | * STATIC FUNCTIONS 79 | **********************/ 80 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_circ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_circ.h 3 | * 4 | */ 5 | 6 | #ifndef LV_CIRC_H 7 | #define LV_CIRC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | 14 | /********************* 15 | * INCLUDES 16 | *********************/ 17 | #include 18 | #include "lv_area.h" 19 | #include 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | #define LV_CIRC_OCT1_X(p) (p.x) 25 | #define LV_CIRC_OCT1_Y(p) (p.y) 26 | #define LV_CIRC_OCT2_X(p) (p.y) 27 | #define LV_CIRC_OCT2_Y(p) (p.x) 28 | #define LV_CIRC_OCT3_X(p) (-p.y) 29 | #define LV_CIRC_OCT3_Y(p) (p.x) 30 | #define LV_CIRC_OCT4_X(p) (-p.x) 31 | #define LV_CIRC_OCT4_Y(p) (p.y) 32 | #define LV_CIRC_OCT5_X(p) (-p.x) 33 | #define LV_CIRC_OCT5_Y(p) (-p.y) 34 | #define LV_CIRC_OCT6_X(p) (-p.y) 35 | #define LV_CIRC_OCT6_Y(p) (-p.x) 36 | #define LV_CIRC_OCT7_X(p) (p.y) 37 | #define LV_CIRC_OCT7_Y(p) (-p.x) 38 | #define LV_CIRC_OCT8_X(p) (p.x) 39 | #define LV_CIRC_OCT8_Y(p) (-p.y) 40 | 41 | /********************** 42 | * TYPEDEFS 43 | **********************/ 44 | 45 | /********************** 46 | * GLOBAL PROTOTYPES 47 | **********************/ 48 | 49 | /** 50 | * Initialize the circle drawing 51 | * @param c pointer to a point. The coordinates will be calculated here 52 | * @param tmp point to a variable. It will store temporary data 53 | * @param radius radius of the circle 54 | */ 55 | void lv_circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius); 56 | 57 | /** 58 | * Test the circle drawing is ready or not 59 | * @param c same as in circ_init 60 | * @return true if the circle is not ready yet 61 | */ 62 | bool lv_circ_cont(lv_point_t * c); 63 | 64 | /** 65 | * Get the next point from the circle 66 | * @param c same as in circ_init. The next point stored here. 67 | * @param tmp same as in circ_init. 68 | */ 69 | void lv_circ_next(lv_point_t * c, lv_coord_t * tmp); 70 | 71 | /********************** 72 | * MACROS 73 | **********************/ 74 | 75 | #ifdef __cplusplus 76 | } /* extern "C" */ 77 | #endif 78 | 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_gc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gc.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | #include "lv_gc.h" 11 | 12 | /********************* 13 | * DEFINES 14 | *********************/ 15 | 16 | /********************** 17 | * TYPEDEFS 18 | **********************/ 19 | 20 | /********************** 21 | * STATIC PROTOTYPES 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC VARIABLES 26 | **********************/ 27 | #if (!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0 28 | LV_ROOTS 29 | #endif /* LV_ENABLE_GC */ 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL FUNCTIONS 36 | **********************/ 37 | 38 | /********************** 39 | * STATIC FUNCTIONS 40 | **********************/ 41 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_gc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gc.h 3 | * 4 | */ 5 | 6 | #ifndef LV_GC_H 7 | #define LV_GC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | #ifdef LV_CONF_INCLUDE_SIMPLE 18 | #include "lv_conf.h" 19 | #else 20 | #include "../../lv_conf.h" 21 | #endif 22 | 23 | #include 24 | #include "lv_mem.h" 25 | #include "lv_ll.h" 26 | 27 | /********************* 28 | * DEFINES 29 | *********************/ 30 | 31 | #define LV_GC_ROOTS(prefix) \ 32 | prefix lv_ll_t _lv_task_ll; /*Linked list to store the lv_tasks*/ \ 33 | prefix lv_ll_t _lv_scr_ll; /*Linked list of screens*/ \ 34 | prefix lv_ll_t _lv_drv_ll;\ 35 | prefix lv_ll_t _lv_file_ll;\ 36 | prefix lv_ll_t _lv_anim_ll;\ 37 | prefix void * _lv_def_scr;\ 38 | prefix void * _lv_act_scr;\ 39 | prefix void * _lv_top_layer;\ 40 | prefix void * _lv_sys_layer;\ 41 | prefix void * _lv_task_act;\ 42 | prefix void * _lv_indev_list;\ 43 | prefix void * _lv_disp_list;\ 44 | 45 | #define LV_NO_PREFIX 46 | #define LV_ROOTS LV_GC_ROOTS(LV_NO_PREFIX) 47 | 48 | #if LV_ENABLE_GC == 1 49 | # if LV_MEM_CUSTOM != 1 50 | # error "GC requires CUSTOM_MEM" 51 | # endif /* LV_MEM_CUSTOM */ 52 | #else /* LV_ENABLE_GC */ 53 | # define LV_GC_ROOT(x) x 54 | LV_GC_ROOTS(extern) 55 | #endif /* LV_ENABLE_GC */ 56 | 57 | 58 | /********************** 59 | * TYPEDEFS 60 | **********************/ 61 | 62 | /********************** 63 | * GLOBAL PROTOTYPES 64 | **********************/ 65 | 66 | /********************** 67 | * MACROS 68 | **********************/ 69 | 70 | 71 | #ifdef __cplusplus 72 | } /* extern "C" */ 73 | #endif 74 | 75 | #endif /*LV_GC_H*/ 76 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_log.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_log.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_log.h" 10 | #if USE_LV_LOG 11 | 12 | #if LV_LOG_PRINTF 13 | #include 14 | #include 15 | #include 16 | #include 17 | #endif 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * STATIC PROTOTYPES 28 | **********************/ 29 | 30 | /********************** 31 | * STATIC VARIABLES 32 | **********************/ 33 | static void (*print_cb)(lv_log_level_t, const char *, uint32_t, const char *); 34 | 35 | /********************** 36 | * MACROS 37 | **********************/ 38 | 39 | /********************** 40 | * GLOBAL FUNCTIONS 41 | **********************/ 42 | 43 | /** 44 | * Register custom print (or anything else) function to call when log is added 45 | * @param f a function pointer: 46 | * `void my_print (lv_log_level_t level, const char * file, uint32_t line, const char * dsc)` 47 | */ 48 | void lv_log_register_print(void f(lv_log_level_t, const char *, uint32_t, const char *)) 49 | { 50 | print_cb = f; 51 | } 52 | 53 | /** 54 | * Add a log 55 | * @param level the level of log. (From `lv_log_level_t` enum) 56 | * @param file name of the file when the log added 57 | * @param line line number in the source code where the log added 58 | * @param dsc description of the log 59 | */ 60 | void lv_log_add(lv_log_level_t level, const char * file, int line, const char * dsc) 61 | { 62 | if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/ 63 | 64 | if(level >= LV_LOG_LEVEL) { 65 | 66 | #if LV_LOG_PRINTF && defined(DEBUG_UART_PORT) 67 | static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error"}; 68 | char *log = (char *)malloc(0x1000); 69 | s_printf(log, "%s: %s \t(%s #%d)\r\n", lvl_prefix[level], dsc, file, line); 70 | uart_send(DEBUG_UART_PORT, (u8 *)log, strlen(log) + 1); 71 | //gfx_printf("%s: %s \t(%s #%d)\n", lvl_prefix[level], dsc, file, line); 72 | #else 73 | if(print_cb) print_cb(level, file, line, dsc); 74 | #endif 75 | } 76 | } 77 | 78 | /********************** 79 | * STATIC FUNCTIONS 80 | **********************/ 81 | 82 | #endif /*USE_LV_LOG*/ 83 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_log.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_log.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LOG_H 7 | #define LV_LOG_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | #include 22 | 23 | /********************* 24 | * DEFINES 25 | *********************/ 26 | 27 | /*Possible log level. For compatibility declare it independently from `USE_LV_LOG`*/ 28 | 29 | #define LV_LOG_LEVEL_TRACE 0 /*A lot of logs to give detailed information*/ 30 | #define LV_LOG_LEVEL_INFO 1 /*Log important events*/ 31 | #define LV_LOG_LEVEL_WARN 2 /*Log if something unwanted happened but didn't caused problem*/ 32 | #define LV_LOG_LEVEL_ERROR 3 /*Only critical issue, when the system may fail*/ 33 | #define _LV_LOG_LEVEL_NUM 4 34 | 35 | typedef int8_t lv_log_level_t; 36 | 37 | #if USE_LV_LOG 38 | /********************** 39 | * TYPEDEFS 40 | **********************/ 41 | 42 | 43 | /********************** 44 | * GLOBAL PROTOTYPES 45 | **********************/ 46 | 47 | /** 48 | * Register custom print (or anything else) function to call when log is added 49 | * @param f a function pointer: 50 | * `void my_print (lv_log_level_t level, const char * file, uint32_t line, const char * dsc)` 51 | */ 52 | void lv_log_register_print(void f(lv_log_level_t, const char *, uint32_t, const char *)); 53 | 54 | /** 55 | * Add a log 56 | * @param level the level of log. (From `lv_log_level_t` enum) 57 | * @param file name of the file when the log added 58 | * @param line line number in the source code where the log added 59 | * @param dsc description of the log 60 | */ 61 | void lv_log_add(lv_log_level_t level, const char * file, int line, const char * dsc); 62 | 63 | /********************** 64 | * MACROS 65 | **********************/ 66 | 67 | #define LV_LOG_TRACE(dsc) lv_log_add(LV_LOG_LEVEL_TRACE, __FILE__, __LINE__, dsc); 68 | #define LV_LOG_INFO(dsc) lv_log_add(LV_LOG_LEVEL_INFO, __FILE__, __LINE__, dsc); 69 | #define LV_LOG_WARN(dsc) lv_log_add(LV_LOG_LEVEL_WARN, __FILE__, __LINE__, dsc); 70 | #define LV_LOG_ERROR(dsc) lv_log_add(LV_LOG_LEVEL_ERROR, __FILE__, __LINE__, dsc); 71 | 72 | #else /*USE_LV_LOG*/ 73 | 74 | /*Do nothing if `USE_LV_LOG 0`*/ 75 | #define lv_log_add(level, file, line, dsc) {;} 76 | #define LV_LOG_TRACE(dsc) {;} 77 | #define LV_LOG_INFO(dsc) {;} 78 | #define LV_LOG_WARN(dsc) {;} 79 | #define LV_LOG_ERROR(dsc) {;} 80 | #endif /*USE_LV_LOG*/ 81 | 82 | #ifdef __cplusplus 83 | } /* extern "C" */ 84 | #endif 85 | 86 | #endif /*LV_LOG_H*/ 87 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_math.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file math_base.h 3 | * 4 | */ 5 | 6 | #ifndef LV_MATH_H 7 | #define LV_MATH_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | 14 | /********************* 15 | * INCLUDES 16 | *********************/ 17 | #include 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | #define LV_MATH_MIN(a,b) ((a) < (b) ? (a) : (b)) 23 | #define LV_MATH_MAX(a,b) ((a) > (b) ? (a) : (b)) 24 | #define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x))) 25 | 26 | #define LV_TRIGO_SIN_MAX 32767 27 | #define LV_TRIGO_SHIFT 15 /* >> LV_TRIGO_SHIFT to normalize*/ 28 | 29 | #define LV_BEZIER_VAL_MAX 1024 /*Max time in Bezier functions (not [0..1] to use integers) */ 30 | #define LV_BEZIER_VAL_SHIFT 10 /*log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values*/ 31 | 32 | /********************** 33 | * TYPEDEFS 34 | **********************/ 35 | 36 | /********************** 37 | * GLOBAL PROTOTYPES 38 | **********************/ 39 | /** 40 | * Convert a number to string 41 | * @param num a number 42 | * @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements) 43 | * @return same as `buf` (just for convenience) 44 | */ 45 | char * lv_math_num_to_str(int32_t num, char * buf); 46 | 47 | /** 48 | * Return with sinus of an angle 49 | * @param angle 50 | * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 51 | */ 52 | int16_t lv_trigo_sin(int16_t angle); 53 | 54 | /** 55 | * Calculate a value of a Cubic Bezier function. 56 | * @param t time in range of [0..LV_BEZIER_VAL_MAX] 57 | * @param u0 start values in range of [0..LV_BEZIER_VAL_MAX] 58 | * @param u1 control value 1 values in range of [0..LV_BEZIER_VAL_MAX] 59 | * @param u2 control value 2 in range of [0..LV_BEZIER_VAL_MAX] 60 | * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] 61 | * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] 62 | */ 63 | int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3); 64 | 65 | /********************** 66 | * MACROS 67 | **********************/ 68 | 69 | #ifdef __cplusplus 70 | } /* extern "C" */ 71 | #endif 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_misc.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_font.c 2 | CSRCS += lv_circ.c 3 | CSRCS += lv_area.c 4 | CSRCS += lv_task.c 5 | CSRCS += lv_fs.c 6 | CSRCS += lv_anim.c 7 | CSRCS += lv_mem.c 8 | CSRCS += lv_ll.c 9 | CSRCS += lv_color.c 10 | CSRCS += lv_txt.c 11 | CSRCS += lv_ufs.c 12 | CSRCS += lv_math.c 13 | CSRCS += lv_log.c 14 | CSRCS += lv_gc.c 15 | 16 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_misc 17 | VPATH += :$(LVGL_DIR)/lvgl/lv_misc 18 | 19 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_misc" 20 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_templ.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | /********************* 11 | * DEFINES 12 | *********************/ 13 | 14 | /********************** 15 | * TYPEDEFS 16 | **********************/ 17 | 18 | /********************** 19 | * STATIC PROTOTYPES 20 | **********************/ 21 | 22 | /********************** 23 | * STATIC VARIABLES 24 | **********************/ 25 | 26 | /********************** 27 | * MACROS 28 | **********************/ 29 | 30 | /********************** 31 | * GLOBAL FUNCTIONS 32 | **********************/ 33 | 34 | /********************** 35 | * STATIC FUNCTIONS 36 | **********************/ 37 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_misc/lv_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEMPL_H 7 | #define LV_TEMPL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | 29 | /********************** 30 | * MACROS 31 | **********************/ 32 | 33 | 34 | #ifdef __cplusplus 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #endif /*LV_TEMPL_H*/ 39 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_objx/lv_led.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_led.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LED_H 7 | #define LV_LED_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_LED != 0 23 | 24 | #include "../lv_core/lv_obj.h" 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /*Data of led*/ 35 | typedef struct 36 | { 37 | /*No inherited ext.*/ 38 | /*New data for this type */ 39 | uint8_t bright; /*Current brightness of the LED (0..255)*/ 40 | } lv_led_ext_t; 41 | 42 | /********************** 43 | * GLOBAL PROTOTYPES 44 | **********************/ 45 | 46 | /** 47 | * Create a led objects 48 | * @param par pointer to an object, it will be the parent of the new led 49 | * @param copy pointer to a led object, if not NULL then the new object will be copied from it 50 | * @return pointer to the created led 51 | */ 52 | lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy); 53 | 54 | /** 55 | * Set the brightness of a LED object 56 | * @param led pointer to a LED object 57 | * @param bright 0 (max. dark) ... 255 (max. light) 58 | */ 59 | void lv_led_set_bright(lv_obj_t * led, uint8_t bright); 60 | 61 | /** 62 | * Light on a LED 63 | * @param led pointer to a LED object 64 | */ 65 | void lv_led_on(lv_obj_t * led); 66 | 67 | /** 68 | * Light off a LED 69 | * @param led pointer to a LED object 70 | */ 71 | void lv_led_off(lv_obj_t * led); 72 | 73 | /** 74 | * Toggle the state of a LED 75 | * @param led pointer to a LED object 76 | */ 77 | void lv_led_toggle(lv_obj_t * led); 78 | 79 | /** 80 | * Set the style of a led 81 | * @param led pointer to a led object 82 | * @param style pointer to a style 83 | */ 84 | static inline void lv_led_set_style(lv_obj_t *led, lv_style_t *style) 85 | { 86 | lv_obj_set_style(led, style); 87 | } 88 | 89 | /** 90 | * Get the brightness of a LEd object 91 | * @param led pointer to LED object 92 | * @return bright 0 (max. dark) ... 255 (max. light) 93 | */ 94 | uint8_t lv_led_get_bright(const lv_obj_t * led); 95 | 96 | /** 97 | * Get the style of an led object 98 | * @param led pointer to an led object 99 | * @return pointer to the led's style 100 | */ 101 | static inline lv_style_t* lv_led_get_style(const lv_obj_t *led) 102 | { 103 | return lv_obj_get_style(led); 104 | } 105 | 106 | /********************** 107 | * MACROS 108 | **********************/ 109 | 110 | #endif /*USE_LV_LED*/ 111 | 112 | #ifdef __cplusplus 113 | } /* extern "C" */ 114 | #endif 115 | 116 | #endif /*LV_LED_H*/ 117 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_objx/lv_objx.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_arc.c 2 | CSRCS += lv_bar.c 3 | CSRCS += lv_cb.c 4 | CSRCS += lv_ddlist.c 5 | CSRCS += lv_kb.c 6 | CSRCS += lv_line.c 7 | CSRCS += lv_mbox.c 8 | CSRCS += lv_preload.c 9 | CSRCS += lv_roller.c 10 | CSRCS += lv_table.c 11 | CSRCS += lv_tabview.c 12 | CSRCS += lv_tileview.c 13 | CSRCS += lv_btn.c 14 | CSRCS += lv_calendar.c 15 | CSRCS += lv_chart.c 16 | CSRCS += lv_canvas.c 17 | CSRCS += lv_gauge.c 18 | CSRCS += lv_label.c 19 | CSRCS += lv_list.c 20 | CSRCS += lv_slider.c 21 | CSRCS += lv_ta.c 22 | CSRCS += lv_spinbox.c 23 | CSRCS += lv_btnm.c 24 | CSRCS += lv_cont.c 25 | CSRCS += lv_img.c 26 | CSRCS += lv_imgbtn.c 27 | CSRCS += lv_led.c 28 | CSRCS += lv_lmeter.c 29 | CSRCS += lv_page.c 30 | CSRCS += lv_sw.c 31 | CSRCS += lv_win.c 32 | 33 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_objx 34 | VPATH += :$(LVGL_DIR)/lvgl/lv_objx 35 | 36 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_objx" 37 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_objx/lv_objx_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.h 3 | * 4 | */ 5 | 6 | 7 | /* TODO Remove these instructions 8 | * Search an replace: template -> object normal name with lower case (e.g. button, label etc.) 9 | * templ -> object short name with lower case(e.g. btn, label etc) 10 | * TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.) 11 | * 12 | */ 13 | 14 | #ifndef LV_TEMPL_H 15 | #define LV_TEMPL_H 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /********************* 22 | * INCLUDES 23 | *********************/ 24 | #ifdef LV_CONF_INCLUDE_SIMPLE 25 | #include "lv_conf.h" 26 | #else 27 | #include "../../lv_conf.h" 28 | #endif 29 | 30 | #if USE_LV_TEMPL != 0 31 | 32 | #include "../lv_core/lv_obj.h" 33 | 34 | /********************* 35 | * DEFINES 36 | *********************/ 37 | 38 | /********************** 39 | * TYPEDEFS 40 | **********************/ 41 | /*Data of template*/ 42 | typedef struct { 43 | lv_ANCESTOR_ext_t ANCESTOR; /*Ext. of ancestor*/ 44 | /*New data for this type */ 45 | } lv_templ_ext_t; 46 | 47 | 48 | /*Styles*/ 49 | enum { 50 | LV_TEMPL_STYLE_X, 51 | LV_TEMPL_STYLE_Y, 52 | }; 53 | typedef uint8_t lv_templ_style_t; 54 | 55 | 56 | /********************** 57 | * GLOBAL PROTOTYPES 58 | **********************/ 59 | 60 | /** 61 | * Create a template objects 62 | * @param par pointer to an object, it will be the parent of the new template 63 | * @param copy pointer to a template object, if not NULL then the new object will be copied from it 64 | * @return pointer to the created template 65 | */ 66 | lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy); 67 | 68 | /*====================== 69 | * Add/remove functions 70 | *=====================*/ 71 | 72 | 73 | /*===================== 74 | * Setter functions 75 | *====================*/ 76 | 77 | /** 78 | * Set a style of a template. 79 | * @param templ pointer to template object 80 | * @param type which style should be set 81 | * @param style pointer to a style 82 | */ 83 | void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, lv_style_t *style); 84 | 85 | /*===================== 86 | * Getter functions 87 | *====================*/ 88 | 89 | /** 90 | * Get style of a template. 91 | * @param templ pointer to template object 92 | * @param type which style should be get 93 | * @return style pointer to the style 94 | */ 95 | lv_style_t * lv_templ_get_style(const lv_obj_t * templ, lv_templ_style_t type); 96 | 97 | /*===================== 98 | * Other functions 99 | *====================*/ 100 | 101 | /********************** 102 | * MACROS 103 | **********************/ 104 | 105 | #endif /*USE_LV_TEMPL*/ 106 | 107 | #ifdef __cplusplus 108 | } /* extern "C" */ 109 | #endif 110 | 111 | #endif /*LV_TEMPL_H*/ 112 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_themes/lv_theme_hekate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2022 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef LV_THEME_HEKATE_H 18 | #define LV_THEME_HEKATE_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /********************* 25 | * INCLUDES 26 | *********************/ 27 | #ifdef LV_CONF_INCLUDE_SIMPLE 28 | #include "lv_conf.h" 29 | #else 30 | #include "../../lv_conf.h" 31 | #endif 32 | 33 | #if USE_LV_THEME_HEKATE 34 | 35 | /********************* 36 | * DEFINES 37 | *********************/ 38 | #define COLOR_HOS_BG_BASE_DEFAULT 0x1B1B1B 39 | #define COLOR_HOS_BG_BASE_BLACK 0x000000 40 | 41 | #define COLOR_HOS_BG_DARKER 0x1B1B1B 42 | #define COLOR_HOS_BG_DARK 0x222222 43 | #define COLOR_HOS_BG 0x2D2D2D 44 | #define COLOR_HOS_BG_LIGHT 0x3D3D3D 45 | #define COLOR_HOS_LIGHT_BORDER 0x4D4D4D 46 | 47 | /********************** 48 | * TYPEDEFS 49 | **********************/ 50 | 51 | /********************** 52 | * GLOBAL PROTOTYPES 53 | **********************/ 54 | 55 | extern uint32_t theme_bg_color; 56 | 57 | /** 58 | * Initialize the material theme 59 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 60 | * @param font pointer to a font (NULL to use the default) 61 | * @return pointer to the initialized theme 62 | */ 63 | lv_theme_t * lv_theme_hekate_init(uint32_t bg_color, uint16_t hue, lv_font_t *font); 64 | 65 | /** 66 | * Get a pointer to the theme 67 | * @return pointer to the theme 68 | */ 69 | lv_theme_t * lv_theme_get_hekate(void); 70 | 71 | /********************** 72 | * MACROS 73 | **********************/ 74 | 75 | #endif 76 | 77 | #ifdef __cplusplus 78 | } /* extern "C" */ 79 | #endif 80 | 81 | #endif /*LV_THEME_MATERIAL_H*/ 82 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_themes/lv_themes.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_theme.c 2 | CSRCS += lv_theme_default.c 3 | CSRCS += lv_theme_templ.c 4 | CSRCS += lv_theme_material.c 5 | 6 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_themes 7 | VPATH += :$(LVGL_DIR)/lvgl/lv_themes 8 | 9 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_themes" 10 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lv_version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_version.h 3 | * 4 | */ 5 | 6 | #ifndef LV_VERSION_H 7 | #define LV_VERSION_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | /*Current version of LittlevGL*/ 17 | #define LVGL_VERSION_MAJOR 5 18 | #define LVGL_VERSION_MINOR 3 19 | #define LVGL_VERSION_PATCH 0 20 | #define LVGL_VERSION_INFO "hekate" 21 | 22 | 23 | /********************* 24 | * DEFINES 25 | *********************/ 26 | 27 | /********************** 28 | * TYPEDEFS 29 | **********************/ 30 | 31 | /********************** 32 | * GLOBAL PROTOTYPES 33 | **********************/ 34 | 35 | /********************** 36 | * MACROS 37 | **********************/ 38 | /* Gives 1 if the x.y.z version is supported in the current version 39 | * Usage: 40 | * 41 | * - Require v6 42 | * #if LV_VERSION_CHECK(6,0,0) 43 | * new_func_in_v6(); 44 | * #endif 45 | * 46 | * 47 | * - Require at least v5.3 48 | * #if LV_VERSION_CHECK(5,3,0) 49 | * new_feature_from_v5_3(); 50 | * #endif 51 | * 52 | * 53 | * - Require v5.3.2 bugfixes 54 | * #if LV_VERSION_CHECK(5,3,2) 55 | * bugfix_in_v5_3_2(); 56 | * #endif 57 | * 58 | * */ 59 | #define LV_VERSION_CHECK(x,y,z) (x == LVGL_VERSION_MAJOR && (y < LVGL_VERSION_MINOR || (y == LVGL_VERSION_MINOR && z <= LVGL_VERSION_PATCH))) 60 | 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | 66 | #endif /*LV_VERSION_H*/ 67 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lvgl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lvgl.h 3 | * Include all LittleV GL related headers 4 | */ 5 | 6 | #ifndef LVGL_H 7 | #define LVGL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | #include "lv_version.h" 18 | 19 | #include "lv_misc/lv_log.h" 20 | #include "lv_misc/lv_task.h" 21 | 22 | #include "lv_hal/lv_hal.h" 23 | 24 | #include "lv_core/lv_obj.h" 25 | #include "lv_core/lv_group.h" 26 | #include "lv_core/lv_lang.h" 27 | #include "lv_core/lv_vdb.h" 28 | #include "lv_core/lv_refr.h" 29 | 30 | #include "lv_themes/lv_theme.h" 31 | 32 | #include "lv_objx/lv_btn.h" 33 | #include "lv_objx/lv_imgbtn.h" 34 | #include "lv_objx/lv_img.h" 35 | #include "lv_objx/lv_label.h" 36 | #include "lv_objx/lv_line.h" 37 | #include "lv_objx/lv_page.h" 38 | #include "lv_objx/lv_cont.h" 39 | #include "lv_objx/lv_list.h" 40 | #include "lv_objx/lv_chart.h" 41 | #include "lv_objx/lv_table.h" 42 | #include "lv_objx/lv_cb.h" 43 | #include "lv_objx/lv_bar.h" 44 | #include "lv_objx/lv_slider.h" 45 | #include "lv_objx/lv_led.h" 46 | #include "lv_objx/lv_btnm.h" 47 | #include "lv_objx/lv_kb.h" 48 | #include "lv_objx/lv_ddlist.h" 49 | #include "lv_objx/lv_roller.h" 50 | #include "lv_objx/lv_ta.h" 51 | #include "lv_objx/lv_canvas.h" 52 | #include "lv_objx/lv_win.h" 53 | #include "lv_objx/lv_tabview.h" 54 | #include "lv_objx/lv_tileview.h" 55 | #include "lv_objx/lv_mbox.h" 56 | #include "lv_objx/lv_gauge.h" 57 | #include "lv_objx/lv_lmeter.h" 58 | #include "lv_objx/lv_sw.h" 59 | #include "lv_objx/lv_kb.h" 60 | #include "lv_objx/lv_arc.h" 61 | #include "lv_objx/lv_preload.h" 62 | #include "lv_objx/lv_calendar.h" 63 | #include "lv_objx/lv_spinbox.h" 64 | 65 | /********************* 66 | * DEFINES 67 | *********************/ 68 | 69 | /********************** 70 | * TYPEDEFS 71 | **********************/ 72 | 73 | /********************** 74 | * GLOBAL PROTOTYPES 75 | **********************/ 76 | 77 | /********************** 78 | * MACROS 79 | **********************/ 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /*LVGL_H*/ 86 | -------------------------------------------------------------------------------- /bdk/libs/lvgl/lvgl.mk: -------------------------------------------------------------------------------- 1 | include $(LVGL_DIR)/lvgl/lv_core/lv_core.mk 2 | include $(LVGL_DIR)/lvgl/lv_hal/lv_hal.mk 3 | include $(LVGL_DIR)/lvgl/lv_objx/lv_objx.mk 4 | include $(LVGL_DIR)/lvgl/lv_fonts/lv_fonts.mk 5 | include $(LVGL_DIR)/lvgl/lv_misc/lv_misc.mk 6 | include $(LVGL_DIR)/lvgl/lv_themes/lv_themes.mk 7 | include $(LVGL_DIR)/lvgl/lv_draw/lv_draw.mk 8 | 9 | -------------------------------------------------------------------------------- /bdk/mem/heap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2024 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _HEAP_H_ 19 | #define _HEAP_H_ 20 | 21 | #include 22 | 23 | typedef struct _hnode 24 | { 25 | int used; 26 | u32 size; 27 | struct _hnode *prev; 28 | struct _hnode *next; 29 | u32 align[4]; // Align to arch cache line size. 30 | } hnode_t; 31 | 32 | typedef struct _heap 33 | { 34 | void *start; 35 | hnode_t *first; 36 | hnode_t *last; 37 | } heap_t; 38 | 39 | typedef struct 40 | { 41 | u32 total; 42 | u32 used; 43 | u32 nodes_total; 44 | u32 nodes_used; 45 | } heap_monitor_t; 46 | 47 | void heap_init(void *base); 48 | void heap_set(heap_t *heap); 49 | void *malloc(u32 size); 50 | void *calloc(u32 num, u32 size); 51 | void *zalloc(u32 size); 52 | void free(void *buf); 53 | void heap_monitor(heap_monitor_t *mon, bool print_node_stats); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /bdk/mem/mc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _MC_H_ 18 | #define _MC_H_ 19 | 20 | #include 21 | #include 22 | 23 | void mc_config_tsec_carveout(u32 bom, u32 size1mb, bool lock); 24 | void mc_config_carveout(); 25 | void mc_config_carveout_finalize(); 26 | void mc_enable_ahb_redirect(); 27 | void mc_disable_ahb_redirect(); 28 | bool mc_client_has_access(void *address); 29 | void mc_enable(); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /bdk/mem/minerva.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _FE_MINERVA_H_ 18 | #define _FE_MINERVA_H_ 19 | 20 | #include "mtc_table.h" 21 | #include 22 | 23 | #define MTC_INIT_MAGIC 0x3043544D 24 | #define MTC_NEW_MAGIC 0x5243544D 25 | 26 | #define EMC_PERIODIC_TRAIN_MS 250 27 | 28 | typedef struct 29 | { 30 | u32 rate_to; 31 | u32 rate_from; 32 | emc_table_t *mtc_table; 33 | u32 table_entries; 34 | emc_table_t *current_emc_table; 35 | u32 train_mode; 36 | u32 sdram_id; 37 | u32 prev_temp; 38 | bool emc_2X_clk_src_is_pllmb; 39 | bool fsp_for_src_freq; 40 | bool train_ram_patterns; 41 | u32 init_done; 42 | } mtc_config_t; 43 | 44 | enum train_mode_t 45 | { 46 | OP_SWITCH = 0, 47 | OP_TRAIN = 1, 48 | OP_TRAIN_SWITCH = 2, 49 | OP_PERIODIC_TRAIN = 3, 50 | OP_TEMP_COMP = 4 51 | }; 52 | 53 | typedef enum 54 | { 55 | FREQ_204 = 204000, 56 | FREQ_408 = 408000, 57 | FREQ_800 = 800000, 58 | FREQ_1333 = 1331200, 59 | FREQ_1600 = 1600000 60 | } minerva_freq_t; 61 | 62 | extern void (*minerva_cfg)(mtc_config_t *mtc_cfg, void *); 63 | u32 minerva_init(); 64 | void minerva_change_freq(minerva_freq_t freq); 65 | void minerva_sdmmc_la_program(void *table, bool t210b01); 66 | void minerva_prep_boot_freq(); 67 | void minerva_prep_boot_l4t(u32 oc_freq, u32 opt_custom); 68 | void minerva_periodic_training(); 69 | emc_table_t *minerva_get_mtc_table(); 70 | int minerva_get_mtc_table_entries(); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /bdk/mem/smmu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2024 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #define MC_SMMU_AVPC_ASID 0x23C 23 | #define MC_SMMU_TSEC_ASID 0x294 24 | 25 | #define SMMU_NS BIT(0) 26 | #define SMMU_WRITE BIT(1) 27 | #define SMMU_READ BIT(2) 28 | #define SMMU_ATTR_ALL (SMMU_READ | SMMU_WRITE | SMMU_NS) 29 | 30 | typedef struct _pde_t { 31 | union { 32 | union { 33 | struct { 34 | u32 table:22; 35 | u32 rsvd:6; 36 | u32 next:1; 37 | u32 attr:3; 38 | } tbl; 39 | 40 | struct { 41 | u32 rsvd_:10; 42 | u32 page:12; 43 | u32 rsvd:6; 44 | u32 next:1; 45 | u32 attr:3; 46 | } huge; 47 | }; 48 | 49 | u32 pde; 50 | }; 51 | } pde_t; 52 | 53 | typedef struct _pte_t { 54 | u32 page:22; 55 | u32 rsvd:7; 56 | u32 attr:3; 57 | } pte_t; 58 | 59 | static_assert(sizeof(pde_t) == sizeof(u32), "pde_t size is wrong!"); 60 | static_assert(sizeof(pte_t) == sizeof(u32), "pte_t size is wrong!"); 61 | 62 | void *smmu_page_zalloc(u32 num); 63 | void smmu_flush_all(); 64 | void smmu_init(); 65 | void smmu_enable(); 66 | void smmu_reset_heap(); 67 | void *smmu_init_domain(u32 dev_base, u32 asid); 68 | void smmu_deinit_domain(u32 dev_base, u32 asid); 69 | void smmu_domain_bypass(u32 dev_base, bool bypass); 70 | void smmu_map(void *ptb, u32 iova, u64 iopa, u32 pages, u32 attr); 71 | void smmu_map_huge(void *ptb, u32 iova, u64 iopa, u32 regions, u32 attr); 72 | -------------------------------------------------------------------------------- /bdk/module.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Common Module Header 3 | * Copyright (c) 2018 M4xw 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _MODULE_H_ 19 | #define _MODULE_H_ 20 | 21 | #include 22 | #include 23 | 24 | #define IANOS_EXT0 0x304E4149 25 | 26 | // Module Callback 27 | typedef void (*cbMainModule_t)(const char *s); 28 | typedef void (*memcpy_t)(void *, void *, size_t); 29 | typedef void (*memset_t)(void *, int, size_t); 30 | typedef int (*reg_voltage_set_t)(u32, u32); 31 | 32 | typedef struct _bdkParams_t 33 | { 34 | void *gfxCon; 35 | void *gfxCtx; 36 | heap_t *sharedHeap; 37 | memcpy_t memcpy; 38 | memset_t memset; 39 | u32 extension_magic; 40 | reg_voltage_set_t reg_voltage_set; 41 | } *bdkParams_t; 42 | 43 | // Module Entrypoint 44 | typedef void (*moduleEntrypoint_t)(void *, bdkParams_t); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /bdk/power/bm92t36.h: -------------------------------------------------------------------------------- 1 | /* 2 | * USB-PD driver for Nintendo Switch's TI BM92T36 3 | * 4 | * Copyright (c) 2020 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef __BM92T36_H_ 20 | #define __BM92T36_H_ 21 | 22 | #include 23 | 24 | #define BM92T36_I2C_ADDR 0x18 25 | 26 | typedef struct _usb_pd_object_t 27 | { 28 | u32 amperage; 29 | u32 voltage; 30 | } usb_pd_object_t; 31 | 32 | typedef struct _usb_pd_objects_t 33 | { 34 | u32 pdo_no; 35 | usb_pd_object_t pdos[7]; 36 | usb_pd_object_t selected_pdo; 37 | } usb_pd_objects_t; 38 | 39 | void bm92t36_get_sink_info(bool *inserted, usb_pd_objects_t *usb_pd); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /bdk/power/regulator_5v.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _REGULATOR_5V_H_ 18 | #define _REGULATOR_5V_H_ 19 | 20 | #include 21 | 22 | enum 23 | { 24 | REGULATOR_5V_FAN = BIT(0), 25 | REGULATOR_5V_JC_R = BIT(1), 26 | REGULATOR_5V_JC_L = BIT(2), 27 | REGULATOR_5V_ALL = 0xFF 28 | }; 29 | 30 | void regulator_5v_enable(u8 dev); 31 | void regulator_5v_disable(u8 dev); 32 | bool regulator_5v_get_dev_enabled(u8 dev); 33 | void regulator_5v_usb_src_enable(bool enable); 34 | 35 | #endif -------------------------------------------------------------------------------- /bdk/sec/se.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2019-2022 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _SE_H_ 19 | #define _SE_H_ 20 | 21 | #include "se_t210.h" 22 | #include 23 | 24 | void se_rsa_acc_ctrl(u32 rs, u32 flags); 25 | void se_key_acc_ctrl(u32 ks, u32 flags); 26 | u32 se_key_acc_ctrl_get(u32 ks); 27 | void se_get_aes_keys(u8 *buf, u8 *keys, u32 keysize); 28 | void se_aes_key_set(u32 ks, const void *key, u32 size); 29 | void se_aes_iv_set(u32 ks, const void *iv); 30 | void se_aes_key_get(u32 ks, void *key, u32 size); 31 | void se_aes_key_clear(u32 ks); 32 | void se_aes_iv_clear(u32 ks); 33 | void se_aes_iv_updated_clear(u32 ks); 34 | int se_aes_unwrap_key(u32 ks_dst, u32 ks_src, const void *input); 35 | int se_aes_crypt_hash(u32 ks, u32 enc, void *dst, u32 dst_size, const void *src, u32 src_size); 36 | int se_aes_crypt_cbc(u32 ks, u32 enc, void *dst, u32 dst_size, const void *src, u32 src_size); 37 | int se_aes_crypt_ecb(u32 ks, u32 enc, void *dst, u32 dst_size, const void *src, u32 src_size); 38 | int se_aes_crypt_block_ecb(u32 ks, u32 enc, void *dst, const void *src); 39 | int se_aes_xts_crypt_sec(u32 tweak_ks, u32 crypt_ks, u32 enc, u64 sec, void *dst, void *src, u32 secsize); 40 | int se_aes_xts_crypt_sec_nx(u32 tweak_ks, u32 crypt_ks, u32 enc, u64 sec, u8 *tweak, bool regen_tweak, u32 tweak_exp, void *dst, void *src, u32 sec_size); 41 | int se_aes_xts_crypt(u32 tweak_ks, u32 crypt_ks, u32 enc, u64 sec, void *dst, void *src, u32 secsize, u32 num_secs); 42 | int se_aes_crypt_ctr(u32 ks, void *dst, u32 dst_size, const void *src, u32 src_size, void *ctr); 43 | int se_calc_sha256(void *hash, u32 *msg_left, const void *src, u32 src_size, u64 total_size, u32 sha_cfg, bool is_oneshot); 44 | int se_calc_sha256_oneshot(void *hash, const void *src, u32 src_size); 45 | int se_calc_sha256_finalize(void *hash, u32 *msg_left); 46 | int se_gen_prng128(void *dst); 47 | int se_aes_cmac_128(u32 ks, void *dst, const void *src, u32 src_size); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /bdk/sec/tsec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2024 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _TSEC_H_ 19 | #define _TSEC_H_ 20 | 21 | #include 22 | 23 | enum tsec_fw_type 24 | { 25 | // Retail Hovi Keygen. 26 | TSEC_FW_TYPE_OLD = 0, // 1.0.0 - 6.1.0. 27 | TSEC_FW_TYPE_EMU = 1, // 6.2.0 emulated environment. 28 | TSEC_FW_TYPE_NEW = 2, // 7.0.0+. 29 | }; 30 | 31 | typedef struct _tsec_ctxt_t 32 | { 33 | void *fw; 34 | u32 size; 35 | u32 type; 36 | void *pkg1; 37 | u32 pkg11_off; 38 | } tsec_ctxt_t; 39 | 40 | int tsec_query(void *tsec_keys, tsec_ctxt_t *tsec_ctxt); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /bdk/sec/tsec_t210.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2023 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _TSEC_T210_H_ 18 | #define _TSEC_T210_H_ 19 | 20 | #define TSEC_MAILBOX0 0x1040 21 | #define TSEC_MAILBOX1 0x1044 22 | #define TSEC_ITFEN 0x1048 23 | #define TSEC_ITFEN_CTXEN BIT(0) 24 | #define TSEC_ITFEN_MTHDEN BIT(1) 25 | #define TSEC_IRQMSET 0x1010 26 | #define TSEC_IRQMSET_WDTMR BIT(1) 27 | #define TSEC_IRQMSET_HALT BIT(4) 28 | #define TSEC_IRQMSET_EXTERR BIT(5) 29 | #define TSEC_IRQMSET_SWGEN0 BIT(6) 30 | #define TSEC_IRQMSET_SWGEN1 BIT(7) 31 | #define TSEC_IRQMSET_EXT(val) (((val) & 0xFF) << 8) 32 | #define TSEC_IRQDEST 0x101C 33 | #define TSEC_IRQDEST_HALT BIT(4) 34 | #define TSEC_IRQDEST_EXTERR BIT(5) 35 | #define TSEC_IRQDEST_SWGEN0 BIT(6) 36 | #define TSEC_IRQDEST_SWGEN1 BIT(7) 37 | #define TSEC_IRQDEST_EXT(val) (((val) & 0xFF) << 8) 38 | #define TSEC_CPUCTL 0x1100 39 | #define TSEC_CPUCTL_STARTCPU BIT(1) 40 | #define TSEC_BOOTVEC 0x1104 41 | #define TSEC_DMACTL 0x110C 42 | #define TSEC_DMATRFBASE 0x1110 43 | #define TSEC_DMATRFMOFFS 0x1114 44 | #define TSEC_DMATRFCMD 0x1118 45 | #define TSEC_DMATRFCMD_IDLE BIT(1) 46 | #define TSEC_DMATRFCMD_IMEM BIT(4) 47 | #define TSEC_DMATRFCMD_SIZE_256B (6 << 8) 48 | #define TSEC_DMATRFFBOFFS 0x111C 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /bdk/soc/actmon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Activity Monitor driver for Tegra X1 3 | * 4 | * Copyright (c) 2021 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef __ACTMON_H_ 20 | #define __ACTMON_H_ 21 | 22 | #include 23 | 24 | typedef enum _actmon_dev_t 25 | { 26 | ACTMON_DEV_CPU, 27 | ACTMON_DEV_BPMP, 28 | ACTMON_DEV_AHB, 29 | ACTMON_DEV_APB, 30 | ACTMON_DEV_CPU_FREQ, 31 | ACTMON_DEV_MC_ALL, 32 | ACTMON_DEV_MC_CPU, 33 | 34 | ACTMON_DEV_NUM, 35 | } actmon_dev_t; 36 | 37 | typedef enum _actmon_hist_src_t 38 | { 39 | ACTMON_HIST_SRC_NONE = 0, 40 | ACTMON_HIST_SRC_AHB = 1, 41 | ACTMON_HIST_SRC_APB = 2, 42 | ACTMON_HIST_SRC_BPMP = 3, 43 | ACTMON_HIST_SRC_CPU = 4, 44 | ACTMON_HIST_SRC_MC_ALL = 5, 45 | ACTMON_HIST_SRC_MC_CPU = 6, 46 | ACTMON_HIST_SRC_CPU_FREQ = 7, 47 | ACTMON_HIST_SRC_NA = 8, 48 | ACTMON_HIST_SRC_APB_MMIO = 9, 49 | } actmon_hist_src_t; 50 | 51 | void actmon_hist_enable(actmon_hist_src_t src); 52 | void actmon_hist_disable(); 53 | void actmon_hist_get(u32 *histogram); 54 | void actmon_dev_enable(actmon_dev_t dev); 55 | void actmon_dev_disable(actmon_dev_t dev); 56 | u32 actmon_dev_get_load(actmon_dev_t dev); 57 | u32 actmon_dev_get_load_avg(actmon_dev_t dev); 58 | void atmon_dev_all_disable(); 59 | void actmon_init(); 60 | void actmon_end(); 61 | 62 | #endif -------------------------------------------------------------------------------- /bdk/soc/bpmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BPMP-Lite Cache/MMU and Frequency driver for Tegra X1 3 | * 4 | * Copyright (c) 2019-2024 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef _BPMP_H_ 20 | #define _BPMP_H_ 21 | 22 | #include 23 | 24 | typedef enum 25 | { 26 | BPMP_MMU_MAINT_NOP = 0, 27 | BPMP_MMU_MAINT_CLEAN_PHY = 1, 28 | BPMP_MMU_MAINT_INVALID_PHY = 2, 29 | BPMP_MMU_MAINT_CLEAN_INVALID_PHY = 3, 30 | BPMP_MMU_MAINT_CLEAN_LINE = 9, 31 | BPMP_MMU_MAINT_INVALID_LINE = 10, 32 | BPMP_MMU_MAINT_CLEAN_INVALID_LINE = 11, 33 | BPMP_MMU_MAINT_CLEAN_WAY = 17, 34 | BPMP_MMU_MAINT_INVALID_WAY = 18, 35 | BPMP_MMU_MAINT_CLN_INV_WAY = 19 36 | } bpmp_maintenance_t; 37 | 38 | typedef struct _bpmp_mmu_entry_t 39 | { 40 | u32 start_addr; 41 | u32 end_addr; 42 | u32 attr; 43 | u32 enable; 44 | } bpmp_mmu_entry_t; 45 | 46 | typedef enum 47 | { 48 | BPMP_CLK_NORMAL, // 408MHz 0% - 136MHz APB. 49 | BPMP_CLK_HIGH_BOOST, // 544MHz 33% - 136MHz APB. 50 | BPMP_CLK_HIGH2_BOOST, // 563MHz 38% - 141MHz APB. 51 | BPMP_CLK_SUPER_BOOST, // 576MHz 41% - 144MHz APB. 52 | BPMP_CLK_HYPER_BOOST, // 589MHz 44% - 147MHz APB. 53 | //BPMP_CLK_DEV_BOOST, // 608MHz 49% - 152MHz APB. 54 | BPMP_CLK_MAX 55 | } bpmp_freq_t; 56 | 57 | typedef enum 58 | { 59 | BPMP_STATE_STANDBY = 0, // 32KHz. 60 | BPMP_STATE_IDLE = 1, 61 | BPMP_STATE_RUN = 2, 62 | 63 | BPMP_STATE_IRQ = BIT(2), 64 | BPMP_STATE_FIQ = BIT(3), 65 | } bpmp_state_t; 66 | 67 | #define BPMP_CLK_LOWEST_BOOST BPMP_CLK_HIGH2_BOOST 68 | #define BPMP_CLK_LOWER_BOOST BPMP_CLK_SUPER_BOOST 69 | #define BPMP_CLK_DEFAULT_BOOST BPMP_CLK_HYPER_BOOST 70 | 71 | void bpmp_mmu_maintenance(u32 op, bool force); 72 | void bpmp_mmu_set_entry(int idx, const bpmp_mmu_entry_t *entry, bool apply); 73 | void bpmp_mmu_enable(); 74 | void bpmp_mmu_disable(); 75 | void bpmp_clk_rate_relaxed(bool enable); 76 | void bpmp_clk_rate_get(); 77 | void bpmp_clk_rate_set(bpmp_freq_t fid); 78 | void bpmp_state_set(bpmp_state_t state); 79 | void bpmp_usleep(u32 us); 80 | void bpmp_msleep(u32 ms); 81 | void bpmp_halt(); 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /bdk/soc/ccplex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _CCPLEX_H_ 18 | #define _CCPLEX_H_ 19 | 20 | #include 21 | 22 | void ccplex_boot_cpu0(u32 entry, bool lock); 23 | void ccplex_powergate_cpu0(); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /bdk/soc/hw_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2024 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _HW_INIT_H_ 19 | #define _HW_INIT_H_ 20 | 21 | #include 22 | 23 | #define BL_MAGIC_CRBOOT_SLD 0x30444C53 // SLD0, seamless display type 0. 24 | #define BL_MAGIC_L4TLDR_SLD 0x31444C53 // SLD1, seamless display type 1. 25 | 26 | extern u32 hw_rst_status; 27 | extern u32 hw_rst_reason; 28 | 29 | void hw_init(); 30 | void hw_deinit(bool coreboot, u32 magic); 31 | void hw_config_arbiter(bool reset); 32 | u32 hw_get_chip_id(); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /bdk/soc/i2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2020 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _I2C_H_ 19 | #define _I2C_H_ 20 | 21 | #include 22 | 23 | #define I2C_1 0 24 | #define I2C_2 1 25 | #define I2C_3 2 26 | #define I2C_4 3 27 | #define I2C_5 4 28 | #define I2C_6 5 29 | 30 | void i2c_init(u32 i2c_idx); 31 | int i2c_recv_buf(u8 *buf, u32 size, u32 i2c_idx, u32 dev_addr); 32 | int i2c_send_buf_big(u32 i2c_idx, u32 dev_addr, u8 *buf, u32 size); 33 | int i2c_recv_buf_big(u8 *buf, u32 size, u32 i2c_idx, u32 dev_addr, u32 reg); 34 | int i2c_send_buf_small(u32 i2c_idx, u32 dev_addr, u32 reg, const u8 *buf, u32 size); 35 | int i2c_recv_buf_small(u8 *buf, u32 size, u32 i2c_idx, u32 dev_addr, u32 reg); 36 | int i2c_send_byte(u32 i2c_idx, u32 dev_addr, u32 reg, u8 val); 37 | u8 i2c_recv_byte(u32 i2c_idx, u32 dev_addr, u32 reg); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /bdk/soc/kfuse.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | int kfuse_wait_ready() 22 | { 23 | // Wait for KFUSE to finish init and verification of data. 24 | while (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_DONE)) 25 | ; 26 | 27 | if (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_CRCPASS)) 28 | return 0; 29 | 30 | return 1; 31 | } 32 | 33 | int kfuse_read(u32 *buf) 34 | { 35 | int res = 0; 36 | 37 | clock_enable_kfuse(); 38 | 39 | if (!kfuse_wait_ready()) 40 | goto out; 41 | 42 | KFUSE(KFUSE_KEYADDR) = KFUSE_KEYADDR_AUTOINC; 43 | for (int i = 0; i < KFUSE_NUM_WORDS; i++) 44 | buf[i] = KFUSE(KFUSE_KEYS); 45 | 46 | res = 1; 47 | 48 | out: 49 | clock_disable_kfuse(); 50 | return res; 51 | } 52 | -------------------------------------------------------------------------------- /bdk/soc/kfuse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _KFUSE_H_ 18 | #define _KFUSE_H_ 19 | 20 | #include 21 | 22 | #define KFUSE_STATE_CURBLOCK_MASK 0x3F 23 | #define KFUSE_STATE_ERRBLOCK_SHIFT 8 24 | #define KFUSE_STATE_ERRBLOCK_MASK 0x3F00 25 | #define KFUSE_STATE_DONE BIT(16) 26 | #define KFUSE_STATE_CRCPASS BIT(17) 27 | #define KFUSE_STATE_RESTART BIT(24) 28 | #define KFUSE_STATE_STOP BIT(25) 29 | #define KFUSE_STATE_SOFTRESET BIT(31) 30 | 31 | #define KFUSE_KEYADDR_AUTOINC BIT(16) 32 | 33 | #define KFUSE_STATE 0x80 34 | #define KFUSE_KEYADDR 0x88 35 | #define KFUSE_KEYS 0x8C 36 | 37 | #define KFUSE_NUM_WORDS 144 38 | 39 | int kfuse_wait_ready(); 40 | int kfuse_read(u32 *buf); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /bdk/soc/pinmux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2024 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | void pinmux_config_uart(u32 idx) 22 | { 23 | PINMUX_AUX(PINMUX_AUX_UARTX_TX(idx)) = 0; 24 | PINMUX_AUX(PINMUX_AUX_UARTX_RX(idx)) = PINMUX_INPUT_ENABLE | PINMUX_TRISTATE; 25 | PINMUX_AUX(PINMUX_AUX_UARTX_RTS(idx)) = 0; 26 | PINMUX_AUX(PINMUX_AUX_UARTX_CTS(idx)) = PINMUX_INPUT_ENABLE | PINMUX_TRISTATE; 27 | } 28 | 29 | void pinmux_config_i2c(u32 idx) 30 | { 31 | PINMUX_AUX(PINMUX_AUX_X_I2C_SCL(idx)) = PINMUX_INPUT_ENABLE; 32 | PINMUX_AUX(PINMUX_AUX_X_I2C_SDA(idx)) = PINMUX_INPUT_ENABLE; 33 | } 34 | 35 | void pinmux_config_i2s(u32 idx) 36 | { 37 | PINMUX_AUX(PINMUX_AUX_X_I2S_LRCK(idx)) = PINMUX_DRIVE_4X | PINMUX_PULL_DOWN; 38 | PINMUX_AUX(PINMUX_AUX_X_I2C_DIN(idx)) = PINMUX_DRIVE_4X | PINMUX_INPUT_ENABLE | PINMUX_TRISTATE | PINMUX_PULL_DOWN; 39 | PINMUX_AUX(PINMUX_AUX_X_I2C_DOUT(idx)) = PINMUX_DRIVE_4X | PINMUX_PULL_DOWN; 40 | PINMUX_AUX(PINMUX_AUX_X_I2C_BCLK(idx)) = PINMUX_DRIVE_4X | PINMUX_PULL_DOWN; 41 | } 42 | -------------------------------------------------------------------------------- /bdk/soc/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Timer/Watchdog driver for Tegra X1 3 | * 4 | * Copyright (c) 2019 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef _TIMER_H_ 20 | #define _TIMER_H_ 21 | 22 | #include 23 | 24 | // TMR registers. 25 | #define TIMERUS_CNTR_1US (0x10 + 0x0) 26 | #define TIMERUS_USEC_CFG (0x10 + 0x4) 27 | #define TIMER_TMR8_TMR_PTV 0x78 28 | #define TIMER_TMR9_TMR_PTV 0x80 29 | #define TIMER_PER_EN BIT(30) 30 | #define TIMER_EN BIT(31) 31 | #define TIMER_TMR8_TMR_PCR 0x7C 32 | #define TIMER_TMR9_TMR_PCR 0x8C 33 | #define TIMER_INTR_CLR BIT(30) 34 | 35 | // WDT registers. 36 | #define TIMER_WDT4_CONFIG (0x100 + 0x80) 37 | #define TIMER_SRC(TMR) ((TMR) & 0xF) 38 | #define TIMER_PER(PER) (((PER) & 0xFF) << 4) 39 | #define TIMER_IRQENABL_EN BIT(12) 40 | #define TIMER_FIQENABL_EN BIT(13) 41 | #define TIMER_SYSRESET_EN BIT(14) 42 | #define TIMER_PMCRESET_EN BIT(15) 43 | #define TIMER_WDT4_COMMAND (0x108 + 0x80) 44 | #define TIMER_START_CNT BIT(0) 45 | #define TIMER_CNT_DISABLE BIT(1) 46 | #define TIMER_WDT4_UNLOCK_PATTERN (0x10C + 0x80) 47 | #define TIMER_MAGIC_PTRN 0xC45A 48 | 49 | u32 get_tmr_us(); 50 | u32 get_tmr_ms(); 51 | u32 get_tmr_s(); 52 | void usleep(u32 us); 53 | void msleep(u32 ms); 54 | #define ILOOP(is) ((is) / 3) 55 | void isleep(u32 is); 56 | 57 | void timer_usleep(u32 us); 58 | 59 | void watchdog_start(u32 us, u32 mode); 60 | void watchdog_end(); 61 | void watchdog_handle(); 62 | bool watchdog_fired(); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /bdk/storage/emmc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2019-2022 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _EMMC_H_ 19 | #define _EMMC_H_ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #define GPT_FIRST_LBA 1 28 | #define GPT_NUM_BLOCKS 33 29 | #define EMMC_BLOCKSIZE SDMMC_DAT_BLOCKSIZE 30 | 31 | enum 32 | { 33 | EMMC_INIT_FAIL = 0, 34 | EMMC_1BIT_HS52 = 1, 35 | EMMC_8BIT_HS52 = 2, 36 | EMMC_MMC_HS200 = 3, 37 | EMMC_MMC_HS400 = 4, 38 | }; 39 | 40 | enum 41 | { 42 | EMMC_ERROR_INIT_FAIL = 0, 43 | EMMC_ERROR_RW_FAIL = 1, 44 | EMMC_ERROR_RW_RETRY = 2 45 | }; 46 | 47 | typedef struct _emmc_part_t 48 | { 49 | u32 index; 50 | u32 lba_start; 51 | u32 lba_end; 52 | u64 attrs; 53 | char name[37]; 54 | link_t link; 55 | } emmc_part_t; 56 | 57 | extern sdmmc_t emmc_sdmmc; 58 | extern sdmmc_storage_t emmc_storage; 59 | extern FATFS emmc_fs; 60 | 61 | void emmc_error_count_increment(u8 type); 62 | u16 *emmc_get_error_count(); 63 | u32 emmc_get_mode(); 64 | int emmc_init_retry(bool power_cycle); 65 | bool emmc_initialize(bool power_cycle); 66 | int emmc_set_partition(u32 partition); 67 | void emmc_end(); 68 | 69 | void emmc_gpt_parse(link_t *gpt); 70 | void emmc_gpt_free(link_t *gpt); 71 | emmc_part_t *emmc_part_find(link_t *gpt, const char *name); 72 | int emmc_part_read(emmc_part_t *part, u32 sector_off, u32 num_sectors, void *buf); 73 | int emmc_part_write(emmc_part_t *part, u32 sector_off, u32 num_sectors, void *buf); 74 | 75 | void nx_emmc_get_autorcm_masks(u8 *mod0, u8 *mod1); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /bdk/storage/mbr_gpt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2019 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef MBR_GPT_H 19 | #define MBR_GPT_H 20 | 21 | #include 22 | 23 | typedef struct _mbr_chs_t 24 | { 25 | u8 head; 26 | u8 sector; 27 | u8 cylinder; 28 | } __attribute__((packed)) mbr_chs_t; 29 | 30 | typedef struct _mbr_part_t 31 | { 32 | u8 status; 33 | mbr_chs_t start_sct_chs; 34 | u8 type; 35 | mbr_chs_t end_sct_chs; 36 | u32 start_sct; 37 | u32 size_sct; 38 | } __attribute__((packed)) mbr_part_t; 39 | 40 | typedef struct _mbr_t 41 | { 42 | /* 0x000 */ u8 bootstrap[440]; 43 | /* 0x1B8 */ u32 signature; 44 | /* 0x1BC */ u16 copy_protected; 45 | /* 0x1BE */ mbr_part_t partitions[4]; 46 | /* 0x1FE */ u16 boot_signature; 47 | } __attribute__((packed)) mbr_t; 48 | 49 | typedef struct _gpt_entry_t 50 | { 51 | /* 0x00 */ u8 type_guid[0x10]; 52 | /* 0x10 */ u8 part_guid[0x10]; 53 | /* 0x20 */ u64 lba_start; 54 | /* 0x28 */ u64 lba_end; 55 | /* 0x30 */ u64 attrs; 56 | /* 0x38 */ u16 name[36]; 57 | } gpt_entry_t; 58 | 59 | typedef struct _gpt_header_t 60 | { 61 | /* 0x00 */ u64 signature; // "EFI PART" 62 | /* 0x08 */ u32 revision; 63 | /* 0x0C */ u32 size; 64 | /* 0x10 */ u32 crc32; 65 | /* 0x14 */ u32 res1; 66 | /* 0x18 */ u64 my_lba; 67 | /* 0x20 */ u64 alt_lba; 68 | /* 0x28 */ u64 first_use_lba; 69 | /* 0x30 */ u64 last_use_lba; 70 | /* 0x38 */ u8 disk_guid[0x10]; 71 | /* 0x48 */ u64 part_ent_lba; 72 | /* 0x50 */ u32 num_part_ents; 73 | /* 0x54 */ u32 part_ent_size; 74 | /* 0x58 */ u32 part_ents_crc32; 75 | /* 0x5C */ u8 res2[420]; // Used as first 3 partition entries backup for HOS. 76 | } gpt_header_t; 77 | 78 | typedef struct _gpt_t 79 | { 80 | gpt_header_t header; 81 | gpt_entry_t entries[128]; 82 | } gpt_t; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /bdk/storage/ramdisk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Ramdisk driver for Tegra X1 3 | * 4 | * Copyright (c) 2019-2021 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #include "ramdisk.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | static u32 disk_size = 0; 30 | 31 | int ram_disk_init(void *ram_fs, u32 ramdisk_size) 32 | { 33 | int res = 0; 34 | disk_size = ramdisk_size; 35 | FATFS *ram_fatfs = (FATFS *)ram_fs; 36 | 37 | // If ramdisk is not raw, format it. 38 | if (ram_fs) 39 | { 40 | u8 *buf = malloc(0x400000); 41 | 42 | // Set ramdisk size. 43 | ramdisk_size >>= 9; 44 | disk_set_info(DRIVE_RAM, SET_SECTOR_COUNT, &ramdisk_size); 45 | 46 | // Unmount ramdisk. 47 | f_mount(NULL, "ram:", 1); 48 | 49 | // Format as exFAT w/ 32KB cluster with no MBR. 50 | res = f_mkfs("ram:", FM_EXFAT | FM_SFD, RAMDISK_CLUSTER_SZ, buf, 0x400000); 51 | 52 | // Mount ramdisk. 53 | if (!res) 54 | res = f_mount(ram_fatfs, "ram:", 1); 55 | 56 | free(buf); 57 | } 58 | 59 | return res; 60 | } 61 | 62 | int ram_disk_read(u32 sector, u32 sector_count, void *buf) 63 | { 64 | u32 sector_off = RAM_DISK_ADDR + (sector << 9); 65 | u32 bytes_count = sector_count << 9; 66 | 67 | if ((sector_off - RAM_DISK_ADDR) > disk_size) 68 | return 1; 69 | 70 | memcpy(buf, (void *)sector_off, bytes_count); 71 | 72 | return 0; 73 | } 74 | 75 | int ram_disk_write(u32 sector, u32 sector_count, const void *buf) 76 | { 77 | u32 sector_off = RAM_DISK_ADDR + (sector << 9); 78 | u32 bytes_count = sector_count << 9; 79 | 80 | if ((sector_off - RAM_DISK_ADDR) > disk_size) 81 | return 1; 82 | 83 | memcpy((void *)sector_off, buf, bytes_count); 84 | 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /bdk/storage/ramdisk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ramdisk driver for Tegra X1 3 | * 4 | * Copyright (c) 2019-2021 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef RAM_DISK_H 20 | #define RAM_DISK_H 21 | 22 | #include 23 | 24 | #define RAMDISK_CLUSTER_SZ 32768 25 | 26 | int ram_disk_init(void *ram_fs, u32 ramdisk_size); 27 | int ram_disk_read(u32 sector, u32 sector_count, void *buf); 28 | int ram_disk_write(u32 sector, u32 sector_count, const void *buf); 29 | 30 | #endif -------------------------------------------------------------------------------- /bdk/storage/sd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2023 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef SD_H 19 | #define SD_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #define SD_BLOCKSIZE SDMMC_DAT_BLOCKSIZE 26 | 27 | enum 28 | { 29 | SD_INIT_FAIL = 0, 30 | SD_1BIT_HS25 = 1, 31 | SD_4BIT_HS25 = 2, 32 | SD_UHS_SDR82 = 3, 33 | SD_UHS_SDR104 = 4, 34 | #ifdef BDK_SDMMC_UHS_DDR200_SUPPORT 35 | SD_UHS_DDR208 = 5 36 | #endif 37 | 38 | }; 39 | 40 | enum 41 | { 42 | SD_ERROR_INIT_FAIL = 0, 43 | SD_ERROR_RW_FAIL = 1, 44 | SD_ERROR_RW_RETRY = 2 45 | }; 46 | 47 | extern sdmmc_t sd_sdmmc; 48 | extern sdmmc_storage_t sd_storage; 49 | extern FATFS sd_fs; 50 | 51 | void sd_error_count_increment(u8 type); 52 | u16 *sd_get_error_count(); 53 | bool sd_get_card_removed(); 54 | bool sd_get_card_initialized(); 55 | bool sd_get_card_mounted(); 56 | u32 sd_get_mode(); 57 | int sd_init_retry(bool power_cycle); 58 | bool sd_initialize(bool power_cycle); 59 | bool sd_mount(); 60 | void sd_unmount(); 61 | void sd_end(); 62 | bool sd_is_gpt(); 63 | void *sd_file_read(const char *path, u32 *fsize); 64 | int sd_save_to_file(const void *buf, u32 size, const char *filename); 65 | 66 | #endif -------------------------------------------------------------------------------- /bdk/thermal/fan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Fan driver for Nintendo Switch 3 | * 4 | * Copyright (c) 2018-2024 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef __FAN_H_ 20 | #define __FAN_H_ 21 | 22 | #include 23 | 24 | // Disable: 0 (0 RPM), min duty: 1 (960 RPM), max duty 235 (11000 RPM). 25 | void fan_set_duty(u32 duty); 26 | // Passing NULL ptr on either of the two, disables results. 27 | void fan_get_speed(u32 *duty, u32 *rpm); 28 | 29 | void fan_set_from_temp(u32 temp); 30 | 31 | #endif /* __FAN_H_ */ 32 | -------------------------------------------------------------------------------- /bdk/thermal/tmp451.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SOC/PCB Temperature driver for Nintendo Switch's TI TMP451 3 | * 4 | * Copyright (c) 2018-2020 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | u16 tmp451_get_soc_temp(bool intenger) 25 | { 26 | u8 val; 27 | u16 temp = 0; 28 | 29 | val = i2c_recv_byte(I2C_1, TMP451_I2C_ADDR, TMP451_SOC_TEMP_REG); 30 | if (intenger) 31 | return val; 32 | 33 | temp = val << 8; 34 | val = i2c_recv_byte(I2C_1, TMP451_I2C_ADDR, TMP451_SOC_TMP_DEC_REG); 35 | temp |= ((val >> 4) * 625) / 100; 36 | 37 | return temp; 38 | } 39 | 40 | u16 tmp451_get_pcb_temp(bool intenger) 41 | { 42 | u8 val; 43 | u16 temp = 0; 44 | 45 | val = i2c_recv_byte(I2C_1, TMP451_I2C_ADDR, TMP451_PCB_TEMP_REG); 46 | if (intenger) 47 | return val; 48 | 49 | temp = val << 8; 50 | val = i2c_recv_byte(I2C_1, TMP451_I2C_ADDR, TMP451_PCB_TMP_DEC_REG); 51 | temp |= ((val >> 4) * 625) / 100; 52 | 53 | return temp; 54 | } 55 | 56 | void tmp451_init() 57 | { 58 | // Disable ALARM and Range to 0 - 127 oC. 59 | i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CONFIG_REG, 0x80); 60 | 61 | // Set remote sensor offsets based on SoC. 62 | if (hw_get_chip_id() == GP_HIDREV_MAJOR_T210) 63 | { 64 | // Set offset to 0 oC for Erista. 65 | i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_SOC_TMP_OFH_REG, 0); 66 | i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_SOC_TMP_OFL_REG, 0); 67 | } 68 | else 69 | { 70 | // Set offset to -12.5 oC for Mariko. 71 | i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_SOC_TMP_OFH_REG, 0xF3); // - 13 oC. 72 | i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_SOC_TMP_OFL_REG, 0x80); // + 0.5 oC. 73 | } 74 | 75 | // Set conversion rate to 32/s and make a read to update the reg. 76 | i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CNV_RATE_REG, 9); 77 | tmp451_get_soc_temp(false); 78 | 79 | // Set rate to every 4 seconds. 80 | i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CNV_RATE_REG, 2); 81 | } 82 | 83 | void tmp451_end() 84 | { 85 | // Place into shutdown mode to conserve power. 86 | i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CONFIG_REG, 0xC0); 87 | } 88 | -------------------------------------------------------------------------------- /bdk/thermal/tmp451.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SOC/PCB Temperature driver for Nintendo Switch's TI TMP451 3 | * 4 | * Copyright (c) 2018 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef __TMP451_H_ 20 | #define __TMP451_H_ 21 | 22 | #include 23 | 24 | #define TMP451_I2C_ADDR 0x4C 25 | 26 | #define TMP451_PCB_TEMP_REG 0x00 27 | #define TMP451_SOC_TEMP_REG 0x01 28 | 29 | #define TMP451_CONFIG_REG 0x09 30 | #define TMP451_CNV_RATE_REG 0x0A 31 | 32 | #define TMP451_SOC_TMP_DEC_REG 0x10 33 | #define TMP451_PCB_TMP_DEC_REG 0x15 34 | 35 | #define TMP451_SOC_TMP_OFH_REG 0x11 36 | #define TMP451_SOC_TMP_OFL_REG 0x12 37 | 38 | // If input is false, the return value is packed. MSByte is the integer in oC 39 | // and the LSByte is the decimal point truncated to 2 decimal places. 40 | // Otherwise it's an integer oC. 41 | u16 tmp451_get_soc_temp(bool integer); 42 | u16 tmp451_get_pcb_temp(bool integer); 43 | void tmp451_init(); 44 | void tmp451_end(); 45 | 46 | #endif /* __TMP451_H_ */ 47 | -------------------------------------------------------------------------------- /bdk/utils/aarch64_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2019 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _ARM64_H_ 19 | #define _ARM64_H_ 20 | 21 | #include 22 | 23 | #define LSL0 0 24 | #define LSL16 16 25 | #define LSL32 32 26 | 27 | #define _PAGEOFF(x) ((x) & 0xFFFFF000) 28 | 29 | #define _ADRP(r, o) (0x90000000 | ((((o) >> 12) & 0x3) << 29) | ((((o) >> 12) & 0x1FFFFC) << 3) | ((r) & 0x1F)) 30 | #define _BL(a, o) (0x94000000 | ((((o) - (a)) >> 2) & 0x3FFFFFF)) 31 | #define _B(a, o) (0x14000000 | ((((o) - (a)) >> 2) & 0x3FFFFFF)) 32 | #define _MOVKX(r, i, s) (0xF2800000 | (((s) & 0x30) << 17) | (((i) & 0xFFFF) << 5) | ((r) & 0x1F)) 33 | #define _MOVZX(r, i, s) (0xD2800000 | (((s) & 0x30) << 17) | (((i) & 0xFFFF) << 5) | ((r) & 0x1F)) 34 | #define _MOVZW(r, i, s) (0x52800000 | (((s) & 0x30) << 17) | (((i) & 0xFFFF) << 5) | ((r) & 0x1F)) 35 | #define _NOP() 0xD503201F 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /bdk/utils/btn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2022 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _BTN_H_ 19 | #define _BTN_H_ 20 | 21 | #include 22 | 23 | #define BTN_POWER BIT(0) 24 | #define BTN_VOL_DOWN BIT(1) 25 | #define BTN_VOL_UP BIT(2) 26 | #define BTN_HOME BIT(3) 27 | #define BTN_SINGLE BIT(7) 28 | 29 | u8 btn_read(); 30 | u8 btn_read_vol(); 31 | u8 btn_read_home(); 32 | u8 btn_wait(); 33 | u8 btn_wait_timeout(u32 time_ms, u8 mask); 34 | u8 btn_wait_timeout_single(u32 time_ms, u8 mask); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /bdk/utils/dirlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2024 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | 19 | #define DIR_MAX_ENTRIES 64 20 | 21 | typedef struct _dirlist_t 22 | { 23 | char *name[DIR_MAX_ENTRIES]; 24 | char data[DIR_MAX_ENTRIES * 256]; 25 | } dirlist_t; 26 | 27 | dirlist_t *dirlist(const char *directory, const char *pattern, bool includeHiddenFiles, bool parse_dirs); 28 | -------------------------------------------------------------------------------- /bdk/utils/ini.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _INI_H_ 19 | #define _INI_H_ 20 | 21 | #include 22 | #include 23 | 24 | #define INI_CHOICE 3 25 | #define INI_CAPTION 5 26 | #define INI_CHGLINE 6 27 | #define INI_NEWLINE 0xFE 28 | #define INI_COMMENT 0xFF 29 | 30 | typedef struct _ini_kv_t 31 | { 32 | char *key; 33 | char *val; 34 | link_t link; 35 | } ini_kv_t; 36 | 37 | typedef struct _ini_sec_t 38 | { 39 | char *name; 40 | link_t kvs; 41 | link_t link; 42 | u32 type; 43 | u32 color; 44 | } ini_sec_t; 45 | 46 | int ini_parse(link_t *dst, const char *ini_path, bool is_dir); 47 | char *ini_check_special_section(ini_sec_t *cfg); 48 | void ini_free(link_t *src); 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /bdk/utils/sprintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _SPRINTF_H_ 18 | #define _SPRINTF_H_ 19 | 20 | #include 21 | 22 | #include 23 | 24 | /* 25 | * Padding: 26 | * Numbers: 27 | * %3d: Fill: ' ', Count: 3. 28 | * % 3d: Fill: ' ', Count: 3. 29 | * %23d: Fill: '2', Count: 3. 30 | * % 23d: Fill: ' ', Count: 23. 31 | * %223d: Fill: '2', Count: 23. 32 | * 33 | * Strings, Fill: ' ': 34 | * %3s: Count: 5, Left. 35 | * %23s: Count: 5, Left. 36 | * %223s: Count: 25, Left. 37 | * %.3s: Count: 5, Right. 38 | * %.23s: Count: 25, Right. 39 | * %.223s: Count: 225, Right. 40 | */ 41 | 42 | void s_printf(char *out_buf, const char *fmt, ...) __attribute__((format(printf, 2, 3))); 43 | void s_vprintf(char *out_buf, const char *fmt, va_list ap); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /bootloader/config.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2022 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include "config.h" 23 | #include "gfx/tui.h" 24 | #include 25 | 26 | extern hekate_config h_cfg; 27 | 28 | void set_default_configuration() 29 | { 30 | h_cfg.t210b01 = hw_get_chip_id() == GP_HIDREV_MAJOR_T210B01; 31 | 32 | h_cfg.autoboot = 0; 33 | h_cfg.autoboot_list = 0; 34 | h_cfg.bootwait = 3; 35 | h_cfg.noticker = 0; //! TODO: Add GUI option. 36 | h_cfg.backlight = 100; 37 | h_cfg.autohosoff = h_cfg.t210b01 ? 1 : 0; 38 | h_cfg.autonogc = 1; 39 | h_cfg.updater2p = 0; 40 | h_cfg.bootprotect = 0; 41 | 42 | h_cfg.errors = 0; 43 | h_cfg.eks = NULL; 44 | h_cfg.rcm_patched = fuse_check_patched_rcm(); 45 | h_cfg.emummc_force_disable = false; 46 | } 47 | -------------------------------------------------------------------------------- /bootloader/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2022 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _CONFIG_H_ 18 | #define _CONFIG_H_ 19 | 20 | #include 21 | 22 | #include "hos/hos.h" 23 | 24 | typedef struct _hekate_config 25 | { 26 | // Non-volatile config. 27 | u32 autoboot; 28 | u32 autoboot_list; 29 | u32 bootwait; 30 | u32 noticker; 31 | u32 backlight; 32 | u32 autohosoff; 33 | u32 autonogc; 34 | u32 updater2p; 35 | u32 bootprotect; 36 | // Global temporary config. 37 | bool t210b01; 38 | bool emummc_force_disable; 39 | bool rcm_patched; 40 | u32 errors; 41 | hos_eks_mbr_t *eks; 42 | } hekate_config; 43 | 44 | void set_default_configuration(); 45 | 46 | #endif /* _CONFIG_H_ */ 47 | -------------------------------------------------------------------------------- /bootloader/frontend/fe_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2022 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _FE_INFO_H_ 19 | #define _FE_INFO_H_ 20 | 21 | void print_fuseinfo(); 22 | void print_mmc_info(); 23 | void print_sdcard_info(); 24 | void print_fuel_gauge_info(); 25 | void print_battery_charger_info(); 26 | void print_battery_info(); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /bootloader/frontend/fe_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2024 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _FE_TOOLS_H_ 19 | #define _FE_TOOLS_H_ 20 | 21 | void menu_autorcm(); 22 | bool tools_autorcm_enabled(); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /bootloader/gfx/logos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2022 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _GFX_LOGOS_H_ 18 | #define _GFX_LOGOS_H_ 19 | 20 | // 21 x 50 @8bpp RGB. 21 | #define BATTERY_EMPTY_WIDTH 21 22 | #define BATTERY_EMPTY_BATT_HEIGHT 38 23 | #define BATTERY_EMPTY_CHRG_HEIGHT 12 24 | #define BATTERY_EMPTY_SIZE 3150 25 | #define BATTERY_EMPTY_BLZ_SIZE 740 26 | extern u8 battery_icons_blz[]; 27 | 28 | u8 *render_static_bootlogo(); 29 | bool render_ticker_logo(u32 boot_wait, u32 backlight); 30 | bool render_ticker(u32 boot_wait, u32 backlight, bool no_ticker); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /bootloader/gfx/tui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _TUI_H_ 19 | #define _TUI_H_ 20 | 21 | #include 22 | 23 | #define MENT_END 0 24 | #define MENT_HANDLER 1 25 | #define MENT_MENU 2 26 | #define MENT_DATA 3 27 | #define MENT_BACK 4 28 | #define MENT_CAPTION 5 29 | #define MENT_CHGLINE 6 30 | #define MENT_HDLR_RE 7 31 | 32 | typedef struct _ment_t 33 | { 34 | u32 type; 35 | const char *caption; 36 | u32 color; 37 | void *data; 38 | union 39 | { 40 | void(*handler)(void *); 41 | struct _menu_t *menu; 42 | }; 43 | } ment_t; 44 | 45 | typedef struct _menu_t 46 | { 47 | ment_t *ents; 48 | const char *caption; 49 | u32 x; 50 | u32 y; 51 | } menu_t; 52 | 53 | #define MDEF_END() {MENT_END} 54 | #define MDEF_HANDLER(caption, _handler) { MENT_HANDLER, caption, 0, NULL, { .handler = _handler } } 55 | #define MDEF_HANDLER_EX(caption, data, _handler) { MENT_HANDLER, caption, 0, data, { .handler = _handler } } 56 | #define MDEF_MENU(caption, _menu) { MENT_MENU, caption, 0, NULL, { .menu = _menu } } 57 | #define MDEF_BACK() { MENT_BACK, "Back" } 58 | #define MDEF_CAPTION(caption, color) { MENT_CAPTION, caption, color } 59 | #define MDEF_CHGLINE() {MENT_CHGLINE} 60 | 61 | void tui_sbar(bool force_update); 62 | void tui_pbar(int x, int y, u32 val, u32 fgcol, u32 bgcol); 63 | void *tui_do_menu(menu_t *menu); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /bootloader/hos/hos_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _HOS_CONFIG_H_ 18 | #define _HOS_CONFIG_H_ 19 | 20 | #include "hos.h" 21 | 22 | int parse_boot_config(launch_ctxt_t *ctxt); 23 | int config_kip1patch(launch_ctxt_t *ctxt, const char *value); 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /bootloader/hos/pkg2_ini_kippatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _INIPATCH_H_ 18 | #define _INIPATCH_H_ 19 | 20 | #include 21 | 22 | typedef struct _ini_patchset_t 23 | { 24 | char *name; 25 | u32 offset; // section + offset of patch to apply. 26 | u32 length; // In bytes, 0 means last patch. 27 | u8 *src_data; // That must match. 28 | u8 *dst_data; // Gets replaced with. 29 | link_t link; 30 | } ini_patchset_t; 31 | 32 | typedef struct _ini_kip_sec_t 33 | { 34 | char *name; 35 | u8 hash[8]; 36 | link_t pts; 37 | link_t link; 38 | } ini_kip_sec_t; 39 | 40 | int ini_patch_parse(link_t *dst, const char *ini_path); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /bootloader/hos/pkg3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2021 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _PKG3_H_ 18 | #define _PKG3_H_ 19 | 20 | #include "hos.h" 21 | 22 | int parse_pkg3(launch_ctxt_t *ctxt, const char *path); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /bootloader/hos/secmon_exo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2021 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _SECMON_EXO_H_ 18 | #define _SECMON_EXO_H_ 19 | 20 | #include 21 | 22 | void config_exosphere(launch_ctxt_t *ctxt, u32 warmboot_base); 23 | void secmon_exo_check_panic(); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /bootloader/l4t/l4t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * L4T Loader for Tegra X1 3 | * 4 | * Copyright (c) 2020-2022 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef _L4T_H_ 20 | #define _L4T_H_ 21 | 22 | void launch_l4t(const ini_sec_t *ini_sec, int entry_idx, int is_list, bool t210b01); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /bootloader/l4t/l4t_config.inl: -------------------------------------------------------------------------------- 1 | /* 2 | * L4T Loader for Tegra X1 3 | * 4 | * Copyright (c) 2020-2022 CTCaer 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | // Set to 1 to enable early boot debugging. 20 | #define DEBUG_LOG_ATF 0 21 | #define DEBUG_LOG_BPMPFW 0 // Do not enable if UART setup is hindered during early boot. 22 | 23 | // Set to 1 to lock PMC registers that contain LP0 parameters. 24 | #define LOCK_PMC_REGISTERS 0 25 | 26 | // Configurable carveout enable config. Only one can be enabled at a time. 27 | #define CARVEOUT_NVDEC_TSEC_ENABLE 0 // Enable for NVDEC bl/prod and full TOS/DRM. 28 | #define CARVEOUT_SECFW_ENABLE 1 // SECFW is always allocated even if carveout is disabled. 29 | 30 | /* 31 | * WPR Carveout size config. 32 | * 33 | * L4T: 2MB or 13MB. On non SecureOS env, only 0x100 bytes are used, probably also on full TOS. 34 | * On 4GB+ systems, it's normally placed at BANK1_TOP - SIZE; 35 | */ 36 | #define CARVEOUT_GPUWPR_SIZE_CFG (SZ_8M + SZ_4M + SZ_1M) // Mandatory when CARVEOUT_NVDEC_TSEC_ENABLE is 1. 37 | -------------------------------------------------------------------------------- /bootloader/link.ld: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | 3 | SECTIONS { 4 | PROVIDE(__ipl_start = IPL_LOAD_ADDR); 5 | . = __ipl_start; 6 | .text : { 7 | *(.text._start); 8 | KEEP(*(._boot_cfg)); 9 | KEEP(*(._ipl_version)); 10 | *(.text._irq_setup); 11 | *(.text*); 12 | } 13 | .data : { 14 | *(.data*); 15 | *(.rodata*); 16 | } 17 | . = ALIGN(0x10); 18 | __ipl_end = .; 19 | .bss : { 20 | __bss_start = .; 21 | *(COMMON) 22 | *(.bss*) 23 | __bss_end = .; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bootloader/start.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | .section .text._start 18 | .arm 19 | 20 | .extern _reloc_ipl 21 | .type _reloc_ipl, %function 22 | 23 | .extern memset 24 | .type memset, %function 25 | 26 | .extern _irq_setup 27 | .type _irq_setup, %function 28 | 29 | .globl _start 30 | .type _start, %function 31 | _start: 32 | ADR R0, _start 33 | LDR R1, =__ipl_start 34 | CMP R0, R1 35 | BEQ _real_start 36 | 37 | /* If we are not in the right location already, copy a relocator to upper IRAM. */ 38 | ADR R2, _reloc_ipl 39 | LDR R3, =0x4003FF00 40 | MOV R4, #(_real_start - _reloc_ipl) 41 | _copy_loop: 42 | LDMIA R2!, {R5} 43 | STMIA R3!, {R5} 44 | SUBS R4, #4 45 | BNE _copy_loop 46 | 47 | /* Use the relocator to copy ourselves into the right place. */ 48 | LDR R2, =__ipl_end 49 | SUB R2, R2, R1 50 | LDR R3, =_real_start 51 | LDR R4, =0x4003FF00 52 | BX R4 53 | 54 | _reloc_ipl: 55 | LDMIA R0!, {R4-R7} 56 | STMIA R1!, {R4-R7} 57 | SUBS R2, #0x10 58 | BNE _reloc_ipl 59 | /* Jump to the relocated entry. */ 60 | BX R3 61 | 62 | _real_start: 63 | /* Initially, we place our stack under relocator but will move it to under the payload. */ 64 | /* This depends on application scope. */ 65 | LDR SP, =0x4003FF00 66 | LDR R0, =__bss_start 67 | EOR R1, R1, R1 68 | LDR R2, =__bss_end 69 | SUB R2, R2, R0 70 | BL memset 71 | BL _irq_setup 72 | B . 73 | 74 | .globl pivot_stack 75 | .type pivot_stack, %function 76 | pivot_stack: 77 | MOV SP, R0 78 | BX LR 79 | -------------------------------------------------------------------------------- /bootloader/storage/emummc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2021 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef EMUMMC_H 18 | #define EMUMMC_H 19 | 20 | #include 21 | 22 | typedef enum 23 | { 24 | EMUMMC_TYPE_NONE = 0, 25 | EMUMMC_TYPE_PARTITION = 1, 26 | EMUMMC_TYPE_FILES = 2, 27 | } emummc_type_t; 28 | 29 | typedef enum { 30 | EMUMMC_MMC_NAND = 0, 31 | EMUMMC_MMC_SD = 1, 32 | EMUMMC_MMC_GC = 2, 33 | } emummc_mmc_t; 34 | 35 | typedef struct _emummc_cfg_t 36 | { 37 | int enabled; 38 | u64 sector; 39 | u32 id; 40 | char *path; 41 | char *nintendo_path; 42 | // Internal. 43 | char *emummc_file_based_path; 44 | u32 file_based_part_size; 45 | u32 active_part; 46 | int fs_ver; 47 | } emummc_cfg_t; 48 | 49 | extern emummc_cfg_t emu_cfg; 50 | 51 | void emummc_load_cfg(); 52 | bool emummc_set_path(char *path); 53 | int emummc_storage_init_mmc(); 54 | int emummc_storage_end(); 55 | int emummc_storage_read(u32 sector, u32 num_sectors, void *buf); 56 | int emummc_storage_write(u32 sector, u32 num_sectors, void *buf); 57 | int emummc_storage_set_mmc_partition(u32 partition); 58 | 59 | #endif -------------------------------------------------------------------------------- /loader/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(strip $(DEVKITARM)),) 2 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 3 | endif 4 | 5 | include $(DEVKITARM)/base_rules 6 | 7 | ################################################################################ 8 | 9 | LDR_LOAD_ADDR := 0x40007000 10 | IPL_MAGIC := 0x43544349 #"ICTC" 11 | include ../Versions.inc 12 | 13 | ################################################################################ 14 | 15 | TARGET := loader 16 | BUILDDIR := ../build 17 | OUTPUTDIR := ../output 18 | BDKDIR := bdk 19 | BDKINC := -I../$(BDKDIR) 20 | VPATH += $(dir $(wildcard ../$(BDKDIR)/*/)) $(dir $(wildcard ../$(BDKDIR)/*/*/)) 21 | 22 | # Main and graphics. 23 | OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \ 24 | start.o loader.o lz.o \ 25 | ) 26 | 27 | ################################################################################ 28 | 29 | CUSTOMDEFINES := -DBL_MAGIC=$(IPL_MAGIC) 30 | CUSTOMDEFINES += -DBL_VER_MJ=$(BLVERSION_MAJOR) -DBL_VER_MN=$(BLVERSION_MINOR) -DBL_VER_HF=$(BLVERSION_HOTFX) -DBL_VER_RL=$(BLVERSION_REL) 31 | 32 | #TODO: Considering reinstating some of these when pointer warnings have been fixed. 33 | WARNINGS := -Wall -Wsign-compare -Wno-array-bounds -Wno-stringop-overflow 34 | 35 | ARCH := -march=armv4t -mtune=arm7tdmi -mthumb-interwork 36 | CFLAGS = $(ARCH) -O2 -g -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -std=gnu11 $(WARNINGS) $(CUSTOMDEFINES) 37 | LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=LDR_LOAD_ADDR=$(LDR_LOAD_ADDR) 38 | 39 | ################################################################################ 40 | 41 | .PHONY: all clean 42 | 43 | all: $(TARGET).bin $(TOOLSLZ) $(TOOLSB2C) 44 | 45 | clean: 46 | @rm -rf $(OBJS) 47 | 48 | $(TARGET).bin: $(BUILDDIR)/$(TARGET)/$(TARGET).elf 49 | @$(OBJCOPY) -S -O binary $< $(OUTPUTDIR)/$(PAYLOAD_NAME).bin 50 | 51 | $(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS) 52 | @$(CC) $(LDFLAGS) -T link.ld $^ -o $@ 53 | 54 | $(BUILDDIR)/$(TARGET)/%.o: %.c 55 | @$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@ 56 | 57 | $(BUILDDIR)/$(TARGET)/%.o: %.S 58 | @$(CC) $(CFLAGS) -c $< -o $@ 59 | 60 | $(OBJS): $(BUILDDIR)/$(TARGET) 61 | 62 | $(BUILDDIR)/$(TARGET): 63 | @mkdir -p "$(BUILDDIR)" 64 | @mkdir -p "$(BUILDDIR)/$(TARGET)" 65 | @mkdir -p "$(OUTPUTDIR)" 66 | -------------------------------------------------------------------------------- /loader/link.ld: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | 3 | SECTIONS { 4 | PROVIDE(__ipl_start = LDR_LOAD_ADDR); 5 | . = __ipl_start; 6 | .text : { 7 | *(.text._start); 8 | KEEP(*(._boot_cfg)); 9 | KEEP(*(._ipl_version)); 10 | KEEP(*(._octopus)); 11 | *(.text*); 12 | } 13 | .data : { 14 | *(.data*); 15 | *(.rodata*); 16 | *(._payload_00); 17 | *(._payload_01); 18 | 19 | /* 20 | * To mitigate bad injectors/chainloaders, 21 | * miss-align binary size to account for version info. 22 | * !If version text is not appended, then use ". = ALIGN(4)"! 23 | */ 24 | data_end_ua = .; 25 | . = ((data_end_ua + 0x6 + 4 - 1) & ~(4 - 1)) - 6; 26 | } 27 | __ldr_end = .; 28 | . = ALIGN(0x10); 29 | __ipl_end = .; 30 | } 31 | -------------------------------------------------------------------------------- /loader/start.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | .section .text._start 18 | .arm 19 | 20 | .extern _reloc_ipl 21 | .type _reloc_ipl, %function 22 | 23 | .extern memset 24 | .type memset, %function 25 | 26 | .extern loader_main 27 | .type loader_main, %function 28 | 29 | .globl _start 30 | .type _start, %function 31 | _start: 32 | ADR R0, _start 33 | LDR R1, =__ipl_start 34 | CMP R0, R1 35 | BEQ _real_start 36 | 37 | /* If we are not in the right location already, copy a relocator to upper IRAM. */ 38 | ADR R2, _reloc_ipl 39 | LDR R3, =0x4003FF00 40 | MOV R4, #(_real_start - _reloc_ipl) 41 | _copy_loop: 42 | LDMIA R2!, {R5} 43 | STMIA R3!, {R5} 44 | SUBS R4, #4 45 | BNE _copy_loop 46 | 47 | /* Use the relocator to copy ourselves into the right place. */ 48 | LDR R2, =__ipl_end 49 | SUB R2, R2, R1 50 | LDR R3, =_real_start 51 | LDR R4, =0x4003FF00 52 | BX R4 53 | 54 | _reloc_ipl: 55 | LDMIA R0!, {R4-R7} 56 | STMIA R1!, {R4-R7} 57 | SUBS R2, #0x10 58 | BNE _reloc_ipl 59 | /* Jump to the relocated entry. */ 60 | BX R3 61 | 62 | _real_start: 63 | /* Initially, we place our stack in IRAM but will move it to SDRAM later. */ 64 | LDR SP, =0x40007000 65 | LDR R0, =__ldr_end 66 | BL loader_main 67 | B . 68 | .word 0 69 | .word 0 70 | .word 0 71 | .word 0 72 | .word 0 73 | .word 0 74 | -------------------------------------------------------------------------------- /modules/hekate_libsys_lp0/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(strip $(DEVKITARM)),) 2 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 3 | endif 4 | 5 | include $(DEVKITARM)/base_rules 6 | 7 | TARGET := libsys_lp0 8 | BUILD := ../../build/$(TARGET) 9 | OUTPUT := ../../output 10 | BDKDIR := bdk 11 | BDKINC := -I../../$(BDKDIR) 12 | 13 | OBJS = $(addprefix $(BUILD)/,\ 14 | sys_sdramlp0.o \ 15 | ) 16 | 17 | ARCH := -march=armv4t -mtune=arm7tdmi -mthumb-interwork 18 | CFLAGS = $(ARCH) -O2 -nostdlib -fpie -ffunction-sections -fdata-sections -fomit-frame-pointer -std=gnu11 -Wall -Wsign-compare $(CUSTOMDEFINES) 19 | LDFLAGS = $(ARCH) -fpie -pie -nostartfiles -lgcc 20 | 21 | .PHONY: clean all 22 | 23 | all: $(TARGET).bso 24 | $(BUILD)/%.o: ./%.c 25 | @mkdir -p "$(BUILD)" 26 | @$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@ 27 | 28 | $(TARGET).bso: $(OBJS) 29 | @$(CC) $(LDFLAGS) -e _modInit $^ -o $(OUTPUT)/$(TARGET).bso 30 | @$(STRIP) -g $(OUTPUT)/$(TARGET).bso 31 | @echo -e "-------------\nBuilt module: "$(TARGET)".bso\n-------------" 32 | 33 | clean: 34 | @rm -rf $(OUTPUT)/$(TARGET).bso 35 | -------------------------------------------------------------------------------- /modules/hekate_libsys_lp0/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _TYPES_H_ 18 | #define _TYPES_H_ 19 | 20 | #define NULL ((void *)0) 21 | 22 | #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) 23 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 24 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 25 | 26 | #define OFFSET_OF(t, m) ((u32)&((t *)NULL)->m) 27 | #define CONTAINER_OF(mp, t, mn) ((t *)((u32)mp - OFFSET_OF(t, mn))) 28 | 29 | typedef char s8; 30 | typedef short s16; 31 | typedef short SHORT; 32 | typedef int s32; 33 | typedef int INT; 34 | typedef long LONG; 35 | typedef long long int s64; 36 | typedef unsigned char u8; 37 | typedef unsigned char BYTE; 38 | typedef unsigned short u16; 39 | typedef unsigned short WORD; 40 | typedef unsigned short WCHAR; 41 | typedef unsigned int u32; 42 | typedef unsigned int UINT; 43 | typedef unsigned long DWORD; 44 | typedef unsigned long long QWORD; 45 | typedef unsigned long long int u64; 46 | typedef volatile unsigned char vu8; 47 | typedef volatile unsigned short vu16; 48 | typedef volatile unsigned int vu32; 49 | 50 | typedef int bool; 51 | #define true 1 52 | #define false 0 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /modules/hekate_libsys_minerva/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(strip $(DEVKITARM)),) 2 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 3 | endif 4 | 5 | include $(DEVKITARM)/base_rules 6 | 7 | TARGET := libsys_minerva 8 | BUILD := ../../build/$(TARGET) 9 | OUTPUT := ../../output 10 | BDKDIR := bdk 11 | BDKINC := -I../../$(BDKDIR) 12 | 13 | OBJS = $(addprefix $(BUILD)/,\ 14 | sys_sdrammtc.o \ 15 | ) 16 | 17 | ARCH := -march=armv4t -mtune=arm7tdmi -mthumb-interwork 18 | CFLAGS = $(ARCH) -O2 -nostdlib -fpie -ffunction-sections -fdata-sections -fomit-frame-pointer -std=gnu11 -Wall -Wsign-compare $(CUSTOMDEFINES) 19 | LDFLAGS = $(ARCH) -fpie -pie -nostartfiles -lgcc 20 | 21 | .PHONY: clean all 22 | 23 | all: $(TARGET).bso 24 | $(BUILD)/%.o: ./%.c 25 | @mkdir -p "$(BUILD)" 26 | @$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@ 27 | 28 | $(TARGET).bso: $(OBJS) 29 | @$(CC) $(LDFLAGS) -e _minerva_init $^ -o $(OUTPUT)/$(TARGET).bso 30 | @$(STRIP) -g $(OUTPUT)/$(TARGET).bso 31 | @echo -e "-------------\nBuilt module: "$(TARGET)".bso\n-------------" 32 | 33 | clean: 34 | @rm -rf $(OUTPUT)/$(TARGET).bso 35 | -------------------------------------------------------------------------------- /modules/hekate_libsys_minerva/README.md: -------------------------------------------------------------------------------- 1 | # Minerva Training Cell 2 | 3 | ### Custom Nvidia Tegra X1 DRAM trainer. 4 | 5 | For more, check [Here](https://github.com/CTCaer/minerva_tc). 6 | 7 | 8 | 9 | ``` 10 | Minerva Training Cell (c) 2018 CTCaer. 11 | 12 | /* Pain... And suffering. */ 13 | ``` 14 | -------------------------------------------------------------------------------- /modules/hekate_libsys_minerva/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _TYPES_H_ 18 | #define _TYPES_H_ 19 | 20 | #define NULL ((void *)0) 21 | 22 | #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) 23 | #define BIT(n) (1U << (n)) 24 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 25 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 26 | 27 | #define OFFSET_OF(t, m) ((u32)&((t *)NULL)->m) 28 | #define CONTAINER_OF(mp, t, mn) ((t *)((u32)mp - OFFSET_OF(t, mn))) 29 | 30 | typedef char s8; 31 | typedef short s16; 32 | typedef short SHORT; 33 | typedef int s32; 34 | typedef int INT; 35 | typedef long LONG; 36 | typedef long long int s64; 37 | typedef unsigned char u8; 38 | typedef unsigned char BYTE; 39 | typedef unsigned short u16; 40 | typedef unsigned short WORD; 41 | typedef unsigned short WCHAR; 42 | typedef unsigned int u32; 43 | typedef unsigned int UINT; 44 | typedef unsigned long DWORD; 45 | typedef unsigned long long QWORD; 46 | typedef unsigned long long int u64; 47 | typedef volatile unsigned char vu8; 48 | typedef volatile unsigned short vu16; 49 | typedef volatile unsigned int vu32; 50 | 51 | typedef int bool; 52 | #define true 1 53 | #define false 0 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /modules/simple_sample/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(strip $(DEVKITARM)),) 2 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 3 | endif 4 | 5 | include $(DEVKITARM)/base_rules 6 | 7 | TARGET := module_sample 8 | BUILD := ../../build/$(TARGET) 9 | OUTPUT := ../../output 10 | SOURCEDIR = simple_sample 11 | BDKDIR := bdk 12 | BDKINC := -I../../$(BDKDIR) 13 | VPATH = $(dir ./) $(dir $(wildcard ./*/)) 14 | 15 | OBJS = $(addprefix $(BUILD)/,\ 16 | module_sample.o \ 17 | gfx.o \ 18 | ) 19 | 20 | GFX_INC := '"../modules/$(SOURCEDIR)/gfx/gfx.h"' 21 | 22 | CUSTOMDEFINES := -DGFX_INC=$(GFX_INC) 23 | 24 | ARCH := -march=armv4t -mtune=arm7tdmi -mthumb-interwork 25 | CFLAGS = $(ARCH) -O2 -nostdlib -fpie -ffunction-sections -fdata-sections -fomit-frame-pointer -std=gnu11 -Wall $(CUSTOMDEFINES) 26 | LDFLAGS = $(ARCH) -fpie -pie -nostartfiles -lgcc 27 | 28 | .PHONY: clean all 29 | 30 | all: $(TARGET).bso 31 | $(BUILD)/%.o: ./%.c 32 | @mkdir -p "$(BUILD)" 33 | @$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@ 34 | 35 | $(TARGET).bso: $(OBJS) 36 | @$(CC) $(LDFLAGS) -e _modInit $^ -o $(OUTPUT)/$(TARGET).bso 37 | @$(STRIP) -g $(OUTPUT)/$(TARGET).bso 38 | @echo -e "-------------\nBuilt module: "$(TARGET)".bso\n-------------" 39 | 40 | clean: 41 | @rm -rf $(OUTPUT)/$(TARGET).bso 42 | -------------------------------------------------------------------------------- /modules/simple_sample/gfx/gfx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2020 CTCaer 4 | * Copyright (c) 2018 M4xw 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms and conditions of the GNU General Public License, 8 | * version 2, as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope it will be useful, but WITHOUT 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | * more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef _GFX_H_ 20 | #define _GFX_H_ 21 | 22 | #include 23 | 24 | #define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC) 25 | #define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC) 26 | #define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC) 27 | #define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC) 28 | 29 | typedef struct _gfx_ctxt_t 30 | { 31 | u32 *fb; 32 | u32 width; 33 | u32 height; 34 | u32 stride; 35 | } gfx_ctxt_t; 36 | 37 | typedef struct _gfx_con_t 38 | { 39 | gfx_ctxt_t *gfx_ctxt; 40 | u32 fntsz; 41 | u32 x; 42 | u32 y; 43 | u32 savedx; 44 | u32 savedy; 45 | u32 fgcol; 46 | int fillbg; 47 | u32 bgcol; 48 | bool mute; 49 | } gfx_con_t; 50 | 51 | // Global gfx console and context. 52 | extern gfx_ctxt_t gfx_ctxt; 53 | extern gfx_con_t gfx_con; 54 | 55 | void gfx_init_ctxt(u32 *fb, u32 width, u32 height, u32 stride); 56 | void gfx_clear_grey(u8 color); 57 | void gfx_clear_partial_grey(u8 color, u32 pos_x, u32 height); 58 | void gfx_clear_color(u32 color); 59 | void gfx_con_init(); 60 | void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol); 61 | void gfx_con_getpos(u32 *x, u32 *y); 62 | void gfx_con_setpos(u32 x, u32 y); 63 | void gfx_putc(char c); 64 | void gfx_puts(char *s); 65 | void gfx_printf(const char *fmt, ...); 66 | void gfx_hexdump(u32 base, const u8 *buf, u32 len); 67 | 68 | void gfx_set_pixel(u32 x, u32 y, u32 color); 69 | void gfx_line(int x0, int y0, int x1, int y1, u32 color); 70 | void gfx_put_small_sep(); 71 | void gfx_put_big_sep(); 72 | void gfx_set_rect_grey(const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); 73 | void gfx_set_rect_rgb(const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); 74 | void gfx_set_rect_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); 75 | void gfx_render_bmp_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /modules/simple_sample/module_sample.c: -------------------------------------------------------------------------------- 1 | /* Sample Hekate Module 2 | 2018 - M4xw 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void _modInit(void *moduleConfig, bdkParams_t bp) 10 | { 11 | memcpy(&gfx_con, bp->gfxCon, sizeof(gfx_con_t)); 12 | memcpy(&gfx_ctxt, bp->gfxCtx, sizeof(gfx_ctxt_t)); 13 | 14 | gfx_puts("Hello World!"); 15 | 16 | memcpy(bp->gfxCon, &gfx_con, sizeof(gfx_con_t)); 17 | memcpy(bp->gfxCtx, &gfx_ctxt, sizeof(gfx_ctxt_t)); 18 | } 19 | -------------------------------------------------------------------------------- /nyx/README_RES.md: -------------------------------------------------------------------------------- 1 | # Nyx - Background - Icons 2 | 3 | The background for Nyx, must be a 1280 x 720 32-bit BMP. Alpha blending is taken into account. For that reason, if a solid background is required, that value must be 0xFF. There are sites that can produce the correct bmp. 4 | 5 | The icons supported are 192 x 192 32-bit BMP. You can utilize transparency at will and make nice mixes with the button background. 6 | 7 | Additionally, using the `icon={sd path}`, the icon will get colorized if the name ends in `_hue.bmp`. That only works nicely if the icon is a white layout with transparency. 8 | 9 | If `_nobox.bmp` is used then the button background is removed. Useful for icon themes that aim for a specific style. 10 | 11 | A combo of both can be enabled via `_hue_nobox.bmp` suffix. 12 | 13 | The default system icons (`icon_switch.bmp` and `icon_payload.bmp`) can be replaced with white layouts that have transparency. They can also be replaced with normal icons if the following exist: `icon_switch_custom.bmp` or/and `icon_payload_custom.bmp` 14 | 15 | 16 | ## How to configure 17 | 18 | The background must go to /bootloader/res/background.bmp 19 | 20 | The icons can be utilized either via `[boot entries names]` -> `boot entries names.bmp` or by using `icon={sd path}` (preferred method), which should point at a bmp. 21 | -------------------------------------------------------------------------------- /nyx/nyx_gui/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2023 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _CONFIG_H_ 18 | #define _CONFIG_H_ 19 | 20 | #include 21 | 22 | #include "hos/hos.h" 23 | 24 | typedef struct _hekate_config 25 | { 26 | // Non-volatile config. 27 | u32 autoboot; 28 | u32 autoboot_list; 29 | u32 bootwait; 30 | u32 noticker; 31 | u32 backlight; 32 | u32 autohosoff; 33 | u32 autonogc; 34 | u32 updater2p; 35 | u32 bootprotect; 36 | // Global temporary config. 37 | bool t210b01; 38 | bool emummc_force_disable; 39 | bool rcm_patched; 40 | bool autorcm_enabled; 41 | u32 errors; 42 | hos_eks_mbr_t *eks; 43 | } hekate_config; 44 | 45 | typedef struct _nyx_config 46 | { 47 | u32 theme_bg; 48 | u32 theme_color; 49 | u32 entries_5_col; 50 | u32 timeoff; 51 | u32 home_screen; 52 | u32 verification; 53 | u32 ums_emmc_rw; 54 | u32 jc_disable; 55 | u32 jc_force_right; 56 | u32 bpmp_clock; 57 | } nyx_config; 58 | 59 | void set_default_configuration(); 60 | void set_nyx_default_configuration(); 61 | int create_config_entry(); 62 | int create_nyx_config_entry(bool force_unmount); 63 | 64 | #endif /* _CONFIG_H_ */ 65 | -------------------------------------------------------------------------------- /nyx/nyx_gui/frontend/fe_emmc_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Rajko Stojadinovic 3 | * Copyright (c) 2018 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _FE_EMMC_TOOLS_H_ 19 | #define _FE_EMMC_TOOLS_H_ 20 | 21 | #include "gui.h" 22 | 23 | typedef enum 24 | { 25 | PART_BOOT = BIT(0), 26 | PART_SYSTEM = BIT(1), 27 | PART_USER = BIT(2), 28 | PART_RAW = BIT(3), 29 | PART_GP_ALL = BIT(7) 30 | } emmcPartType_t; 31 | 32 | void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui); 33 | void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /nyx/nyx_gui/frontend/fe_emummc_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Rajko Stojadinovic 3 | * Copyright (c) 2018 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _FE_EMUMMC_TOOLS_H_ 19 | #define _FE_EMUMMC_TOOLS_H_ 20 | 21 | #include "gui.h" 22 | 23 | typedef struct _emummc_cfg_t 24 | { 25 | int enabled; 26 | u32 sector; 27 | u16 id; 28 | char *path; 29 | char *nintendo_path; 30 | } emummc_cfg_t; 31 | 32 | void load_emummc_cfg(emummc_cfg_t *emu_info); 33 | void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path); 34 | void dump_emummc_file(emmc_tool_gui_t *gui); 35 | void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 resized_count); 36 | void update_emummc_base_folder(char *outFilename, u32 sdPathLen, u32 currPartIdx); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /nyx/nyx_gui/frontend/gui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2025 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _GUI_H_ 18 | #define _GUI_H_ 19 | 20 | #include 21 | 22 | typedef struct _emmc_tool_gui_t 23 | { 24 | lv_obj_t *label_log; 25 | lv_obj_t *label_info; 26 | lv_obj_t *label_pct; 27 | lv_obj_t *label_finish; 28 | lv_obj_t *bar; 29 | lv_style_t *bar_teal_bg; 30 | lv_style_t *bar_teal_ind; 31 | lv_style_t *bar_white_ind; 32 | char *txt_buf; 33 | char *base_path; 34 | bool raw_emummc; 35 | } emmc_tool_gui_t; 36 | 37 | typedef struct _gui_status_bar_ctx 38 | { 39 | lv_obj_t *bar_bg; 40 | lv_obj_t *mid; 41 | lv_obj_t *time_temp; 42 | lv_obj_t *temp_symbol; 43 | lv_obj_t *temp_degrees; 44 | lv_obj_t *battery; 45 | lv_obj_t *battery_more; 46 | } gui_status_bar_ctx; 47 | 48 | extern lv_style_t hint_small_style; 49 | extern lv_style_t hint_small_style_white; 50 | extern lv_style_t monospace_text; 51 | 52 | extern lv_obj_t *payload_list; 53 | extern lv_obj_t *autorcm_btn; 54 | extern lv_obj_t *close_btn; 55 | 56 | extern lv_img_dsc_t *icon_switch; 57 | extern lv_img_dsc_t *icon_payload; 58 | extern lv_img_dsc_t *icon_lakka; 59 | 60 | extern lv_img_dsc_t *hekate_bg; 61 | 62 | extern lv_style_t btn_transp_rel, btn_transp_pr, btn_transp_tgl_rel, btn_transp_tgl_pr; 63 | extern lv_style_t ddlist_transp_bg, ddlist_transp_sel; 64 | extern lv_style_t tabview_btn_pr, tabview_btn_tgl_pr; 65 | 66 | extern lv_style_t mbox_darken; 67 | 68 | extern char *text_color; 69 | 70 | extern gui_status_bar_ctx status_bar; 71 | 72 | void reload_nyx(); 73 | lv_img_dsc_t *bmp_to_lvimg_obj(const char *path); 74 | lv_res_t mbox_action(lv_obj_t * btns, const char * txt); 75 | bool nyx_emmc_check_battery_enough(); 76 | lv_res_t nyx_win_close_action_custom(lv_obj_t * btn); 77 | void nyx_window_toggle_buttons(lv_obj_t *win, bool disable); 78 | lv_obj_t *nyx_create_standard_window(const char *win_title); 79 | lv_obj_t *nyx_create_window_custom_close_btn(const char *win_title, lv_action_t rel_action); 80 | void nyx_create_onoff_button(lv_theme_t *th, lv_obj_t *parent, lv_obj_t *btn, const char *btn_name, lv_action_t action, bool transparent); 81 | lv_res_t nyx_generic_onoff_toggle(lv_obj_t *btn); 82 | void manual_system_maintenance(bool refresh); 83 | void nyx_load_and_run(); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /nyx/nyx_gui/frontend/gui_emmc_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _GUI_EMMC_TOOLS_H_ 18 | #define _GUI_EMMC_TOOLS_H_ 19 | 20 | #include 21 | 22 | lv_res_t create_window_backup_restore_tool(lv_obj_t *btn); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /nyx/nyx_gui/frontend/gui_emummc_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _GUI_EMUMMC_TOOLS_H_ 18 | #define _GUI_EMUMMC_TOOLS_H_ 19 | 20 | #include 21 | 22 | lv_res_t create_win_emummc_tools(lv_obj_t *btn); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /nyx/nyx_gui/frontend/gui_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2021 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _GUI_INFO_H_ 18 | #define _GUI_INFO_H_ 19 | 20 | #include 21 | 22 | void create_tab_info(lv_theme_t *th, lv_obj_t *parent); 23 | int dump_cal0(); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /nyx/nyx_gui/frontend/gui_options.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _GUI_OPTIONS_H_ 18 | #define _GUI_OPTIONS_H_ 19 | 20 | #include 21 | 22 | void nyx_options_clear_ini_changes_made(); 23 | bool nyx_options_get_ini_changes_made(); 24 | void first_time_clock_edit(void *param); 25 | lv_res_t create_win_nyx_options(lv_obj_t *parrent_btn); 26 | void create_tab_options(lv_theme_t *th, lv_obj_t *parent); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /nyx/nyx_gui/frontend/gui_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2021 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _GUI_TOOLS_H_ 18 | #define _GUI_TOOLS_H_ 19 | 20 | #include 21 | 22 | extern lv_obj_t *ums_mbox; 23 | 24 | void create_tab_tools(lv_theme_t *th, lv_obj_t *parent); 25 | void nyx_run_ums(void *param); 26 | bool get_set_autorcm_status(bool change); 27 | lv_res_t action_ums_sd(lv_obj_t *btn); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /nyx/nyx_gui/frontend/gui_tools_partition_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef _GUI_TOOLS_PART_MANAGER_H_ 18 | #define _GUI_TOOLS_PART_MANAGER_H_ 19 | 20 | lv_res_t create_window_partition_manager(lv_obj_t *btn); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /nyx/nyx_gui/hos/hos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2024 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _HOS_H_ 19 | #define _HOS_H_ 20 | 21 | #include 22 | 23 | #include "pkg1.h" 24 | #include "pkg2.h" 25 | 26 | #include 27 | 28 | //!TODO: Update on mkey changes. 29 | enum { 30 | HOS_KB_VERSION_100 = 0, 31 | HOS_KB_VERSION_300 = 1, 32 | HOS_KB_VERSION_301 = 2, 33 | HOS_KB_VERSION_400 = 3, 34 | HOS_KB_VERSION_500 = 4, 35 | HOS_KB_VERSION_600 = 5, 36 | HOS_KB_VERSION_620 = 6, 37 | HOS_KB_VERSION_700 = 7, 38 | HOS_KB_VERSION_810 = 8, 39 | HOS_KB_VERSION_900 = 9, 40 | HOS_KB_VERSION_910 = 10, 41 | HOS_KB_VERSION_1210 = 11, 42 | HOS_KB_VERSION_1300 = 12, 43 | HOS_KB_VERSION_1400 = 13, 44 | HOS_KB_VERSION_1500 = 14, 45 | HOS_KB_VERSION_1600 = 15, 46 | HOS_KB_VERSION_1700 = 16, 47 | HOS_KB_VERSION_1800 = 17, 48 | HOS_KB_VERSION_1900 = 18, 49 | HOS_KB_VERSION_2000 = 19, 50 | HOS_KB_VERSION_MAX = HOS_KB_VERSION_2000 51 | }; 52 | 53 | #define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes. 54 | 55 | #define HOS_PKG11_MAGIC 0x31314B50 56 | #define HOS_EKS_MAGIC 0x31534B45 // EKS1. 57 | #define HOS_EKS_TSEC_VER (HOS_KB_VERSION_700 + HOS_TSEC_VERSION) 58 | 59 | typedef struct _hos_eks_mbr_t 60 | { 61 | u32 magic; 62 | u32 enabled; 63 | u32 lot0; 64 | u32 rsvd; 65 | u8 tsec[SE_KEY_128_SIZE]; 66 | u8 troot[SE_KEY_128_SIZE]; 67 | u8 troot_dev[SE_KEY_128_SIZE]; 68 | } hos_eks_mbr_t; 69 | 70 | static_assert(sizeof(hos_eks_mbr_t) == 64, "HOS EKS size is wrong!"); 71 | 72 | typedef struct _launch_ctxt_t 73 | { 74 | void *keyblob; 75 | 76 | void *pkg1; 77 | const pkg1_id_t *pkg1_id; 78 | 79 | void *warmboot; 80 | u32 warmboot_size; 81 | void *secmon; 82 | u32 secmon_size; 83 | 84 | void *pkg2; 85 | u32 pkg2_size; 86 | bool new_pkg2; 87 | 88 | void *kernel; 89 | u32 kernel_size; 90 | link_t kip1_list; 91 | char* kip1_patches; 92 | 93 | ini_sec_t *cfg; 94 | } launch_ctxt_t; 95 | 96 | extern u8 *cal0_buf; 97 | 98 | void hos_eks_clear(u32 kb); 99 | int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt); 100 | int hos_bis_keygen(); 101 | void hos_bis_keys_clear(); 102 | int hos_dump_cal0(); 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /nyx/nyx_gui/hos/pkg1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2022-2023 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _PKG1_H_ 19 | #define _PKG1_H_ 20 | 21 | #include 22 | 23 | #define PKG1_MAGIC 0x31314B50 24 | 25 | #define PK11_SECTION_WB 0 26 | #define PK11_SECTION_LD 1 27 | #define PK11_SECTION_SM 2 28 | 29 | typedef struct _bl_hdr_t210b01_t 30 | { 31 | /* 0x000 */ u8 aes_mac[0x10]; 32 | /* 0x010 */ u8 rsa_sig[0x100]; 33 | /* 0x110 */ u8 salt[0x20]; 34 | /* 0x130 */ u8 sha256[0x20]; 35 | /* 0x150 */ u32 version; 36 | /* 0x154 */ u32 size; 37 | /* 0x158 */ u32 load_addr; 38 | /* 0x15C */ u32 entrypoint; 39 | /* 0x160 */ u8 rsvd[0x10]; 40 | } bl_hdr_t210b01_t; 41 | 42 | typedef struct _pk1_hdr_t 43 | { 44 | /* 0x00 */ u32 si_sha256; // Secure Init. 45 | /* 0x04 */ u32 sm_sha256; // Secure Monitor. 46 | /* 0x08 */ u32 sl_sha256; // Secure Loader. 47 | /* 0x0C */ u32 unk; // what's this? It's not warmboot. 48 | /* 0x10 */ char timestamp[14]; 49 | /* 0x1E */ u8 keygen; 50 | /* 0x1F */ u8 version; 51 | } pk1_hdr_t; 52 | 53 | typedef struct _pkg1_id_t 54 | { 55 | const char *id; 56 | u32 kb; 57 | u32 tsec_off; 58 | u32 pkg11_off; 59 | u32 secmon_base; 60 | u32 warmboot_base; 61 | } pkg1_id_t; 62 | 63 | typedef struct _pk11_hdr_t 64 | { 65 | u32 magic; 66 | u32 wb_size; 67 | u32 wb_off; 68 | u32 pad; 69 | u32 ldr_size; 70 | u32 ldr_off; 71 | u32 sm_size; 72 | u32 sm_off; 73 | } pk11_hdr_t; 74 | 75 | const pkg1_id_t *pkg1_identify(u8 *pkg1, char *build_date); 76 | int pkg1_decrypt(const pkg1_id_t *id, u8 *pkg1); 77 | const u8 *pkg1_unpack(void *wm_dst, void *sm_dst, void *ldr_dst, const pkg1_id_t *id, u8 *pkg1); 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /nyx/nyx_gui/hos/pkg2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * Copyright (c) 2018-2025 CTCaer 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _PKG2_H_ 19 | #define _PKG2_H_ 20 | 21 | #include 22 | 23 | #define PKG2_MAGIC 0x31324B50 24 | #define PKG2_SEC_BASE 0x80000000 25 | #define PKG2_SEC_KERNEL 0 26 | #define PKG2_SEC_INI1 1 27 | #define PKG2_SEC_UNUSED 2 28 | 29 | #define INI1_MAGIC 0x31494E49 30 | 31 | //! TODO: Update on kernel change if needed. 32 | // Offset of OP + 12 is the INI1 offset. On v2 with dynamic crt0 it's + 16. 33 | #define PKG2_NEWKERN_GET_INI1_HEURISTIC 0xD2800015 // MOV X21, #0. 34 | #define PKG2_NEWKERN_START 0x800 35 | 36 | extern u32 pkg2_newkern_ini1_start; 37 | extern u32 pkg2_newkern_ini1_end; 38 | 39 | typedef struct _pkg2_hdr_t 40 | { 41 | u8 ctr[0x10]; 42 | u8 sec_ctr[0x40]; 43 | u32 magic; 44 | u32 base; 45 | u32 pad0; 46 | u8 pkg2_ver; 47 | u8 bl_ver; 48 | u16 pad1; 49 | u32 sec_size[4]; 50 | u32 sec_off[4]; 51 | u8 sec_sha256[0x80]; 52 | u8 data[]; 53 | } pkg2_hdr_t; 54 | 55 | typedef struct _pkg2_ini1_t 56 | { 57 | u32 magic; 58 | u32 size; 59 | u32 num_procs; 60 | u32 pad; 61 | } pkg2_ini1_t; 62 | 63 | typedef struct _pkg2_kip1_sec_t 64 | { 65 | u32 offset; 66 | u32 size_decomp; 67 | u32 size_comp; 68 | u32 attrib; 69 | } pkg2_kip1_sec_t; 70 | 71 | #define KIP1_NUM_SECTIONS 6 72 | 73 | typedef struct _pkg2_kip1_t 74 | { 75 | u32 magic; 76 | u8 name[12]; 77 | u64 tid; 78 | u32 proc_cat; 79 | u8 main_thrd_prio; 80 | u8 def_cpu_core; 81 | u8 res; 82 | u8 flags; 83 | pkg2_kip1_sec_t sections[KIP1_NUM_SECTIONS]; 84 | u32 caps[0x20]; 85 | u8 data[]; 86 | } pkg2_kip1_t; 87 | 88 | typedef struct _pkg2_kip1_info_t 89 | { 90 | pkg2_kip1_t *kip1; 91 | u32 size; 92 | link_t link; 93 | } pkg2_kip1_info_t; 94 | 95 | void pkg2_get_newkern_info(u8 *kern_data); 96 | u32 pkg2_calc_kip1_size(pkg2_kip1_t *kip1); 97 | 98 | pkg2_hdr_t *pkg2_decrypt(void *data, u8 kb); 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /nyx/nyx_gui/link.ld: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | 3 | SECTIONS { 4 | PROVIDE(__ipl_start = NYX_LOAD_ADDR); 5 | . = __ipl_start; 6 | .text : { 7 | *(.text._start); 8 | KEEP(*(._ipl_version)); 9 | *(.text._irq_setup); 10 | *(.text*); 11 | } 12 | .data : { 13 | *(.data*); 14 | *(.rodata*); 15 | } 16 | . = ALIGN(0x10); 17 | __ipl_end = .; 18 | .bss : { 19 | __bss_start = .; 20 | *(COMMON) 21 | *(.bss*) 22 | __bss_end = .; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /nyx/nyx_gui/start.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 naehrwert 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | .section .text._start 18 | .arm 19 | 20 | .extern _reloc_ipl 21 | .type _reloc_ipl, %function 22 | 23 | .extern memset 24 | .type memset, %function 25 | 26 | .extern _irq_setup 27 | .type _irq_setup, %function 28 | 29 | .globl _start 30 | .type _start, %function 31 | _start: 32 | ADR R0, _start 33 | LDR R1, =__ipl_start 34 | CMP R0, R1 35 | BEQ _real_start 36 | 37 | /* If we are not in the right location already, copy a relocator to upper IRAM. */ 38 | ADR R2, _reloc_ipl 39 | LDR R3, =0x4003FF00 40 | MOV R4, #(_real_start - _reloc_ipl) 41 | _copy_loop: 42 | LDMIA R2!, {R5} 43 | STMIA R3!, {R5} 44 | SUBS R4, #4 45 | BNE _copy_loop 46 | 47 | /* Use the relocator to copy ourselves into the right place. */ 48 | LDR R2, =__ipl_end 49 | SUB R2, R2, R1 50 | LDR R3, =_real_start 51 | LDR R4, =0x4003FF00 52 | BX R4 53 | 54 | _reloc_ipl: 55 | LDMIA R0!, {R4-R7} 56 | STMIA R1!, {R4-R7} 57 | SUBS R2, #0x10 58 | BNE _reloc_ipl 59 | /* Jump to the relocated entry. */ 60 | BX R3 61 | 62 | _real_start: 63 | /* We place our stack in SDRAM. */ 64 | LDR SP, =0x4003F000 65 | LDR R0, =__bss_start 66 | EOR R1, R1, R1 67 | LDR R2, =__bss_end 68 | SUB R2, R2, R0 69 | BL memset 70 | BL _irq_setup 71 | B . 72 | 73 | .globl pivot_stack 74 | .type pivot_stack, %function 75 | pivot_stack: 76 | MOV SP, R0 77 | BX LR 78 | -------------------------------------------------------------------------------- /nyx/resources/icon_lakka.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/nyx/resources/icon_lakka.bmp -------------------------------------------------------------------------------- /nyx/resources/icon_lakka_hue.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/nyx/resources/icon_lakka_hue.bmp -------------------------------------------------------------------------------- /nyx/resources/icon_payload.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/nyx/resources/icon_payload.bmp -------------------------------------------------------------------------------- /nyx/resources/icon_switch.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/nyx/resources/icon_switch.bmp -------------------------------------------------------------------------------- /res/bootlogo/bootA_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootA_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootA_caps_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootA_caps_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootA_custom_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootA_custom_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootB_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootB_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootB_caps_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootB_caps_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootB_custom_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootB_custom_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootC_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootC_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootC_ctc_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootC_ctc_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootD_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootD_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootD_ctc_(ARGB).bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootD_ctc_(ARGB).bmp -------------------------------------------------------------------------------- /res/bootlogo/bootlogo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/easyworld/hekate/d3545f5849017a2ae8f26a2d7cd6388cd499650d/res/bootlogo/bootlogo.psd -------------------------------------------------------------------------------- /res/patches_template.ini: -------------------------------------------------------------------------------- 1 | # ASCII non-extended 2 | # A KIP section is [kip1_name:sha256_hex_8bytes] 3 | # A patchset is .patch_name=kip_section_dec:offset_hex_0x:length_hex_0x:src_data_hex,dst_data_hex 4 | # 5 | # _dec: 1 char decimal | _hex_0x: max u32 prefixed with 0x | _hex: hex array. 6 | # Kip1 section decimals: TEXT: 0, RODATA: 1, DATA: 2. 7 | # 8 | # Careful when editing this, otherwise it will fail to be parsed. 9 | # 10 | # Note: the below patches is an obsolete method that was used 11 | # to install homebrew for a qlaunch icon or 3.5GB RAM access. 12 | # This is useless nowadays, because title override or custom qlaunch are a more proper solution. 13 | 14 | #FS Patches for 1.0.0 15 | [FS:de9fdda4085dd5fe] 16 | .nosigchk=0:0x194A0:0x4:BA090094,E0031F2A 17 | .nosigchk=0:0x3A79C:0x4:E0060036,1F2003D5 18 | 19 | #FS Patches for 1.0.0 exfat 20 | [FS:fc3e80991dca1796] 21 | .nosigchk=0:0x194A0:0x4:BA090094,E0031F2A 22 | .nosigchk=0:0x3A79C:0x4:E0060036,1F2003D5 23 | 24 | -------------------------------------------------------------------------------- /tools/bin2c/Makefile: -------------------------------------------------------------------------------- 1 | NATIVE_CC ?= gcc 2 | 3 | ifeq (, $(shell which $(NATIVE_CC) 2>/dev/null)) 4 | $(error "Native GCC is missing. Please install it first. If it's path is custom, set it with export NATIVE_CC=") 5 | endif 6 | 7 | .PHONY: all clean 8 | 9 | all: bin2c 10 | @echo > /dev/null 11 | 12 | clean: 13 | @rm -f bin2c 14 | 15 | bin2c: bin2c.c 16 | @$(NATIVE_CC) -o $@ bin2c.c 17 | -------------------------------------------------------------------------------- /tools/bin2c/bin2c.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This is bin2c program, which allows you to convert binary file to 3 | * C language array, for use as embedded resource, for instance you can 4 | * embed graphics or audio file directly into your program. 5 | * This is public domain software, use it on your own risk. 6 | * Contact Serge Fukanchik at fuxx@mail.ru if you have any questions. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /* Replace . with _ */ 16 | char* 17 | make_ident ( char* name ) 18 | { 19 | char* ret; 20 | char* p; 21 | 22 | ret = strdup ( name ); 23 | 24 | for ( p = ret; p[0]; p++ ) 25 | { 26 | if ( !isalnum ( p[0] ) ) p[0] = '_'; 27 | } 28 | return ret; 29 | } 30 | 31 | int 32 | main ( int argc, char* argv[] ) 33 | { 34 | unsigned char buf[BUFSIZ]; 35 | char* ident; 36 | FILE *fd; 37 | size_t size, i, total, blksize = BUFSIZ; 38 | int need_comma = 0; 39 | 40 | if ( argc != 2 ) 41 | { 42 | fprintf ( stderr, "Usage: %s binary_file > output_file\n", argv[0] ); 43 | return -1; 44 | } 45 | 46 | fd = fopen ( argv[1], "rb" ); 47 | if ( fd == NULL ) 48 | { 49 | fprintf ( stderr, "%s: can't open %s for reading\n", argv[0], argv[1] ); 50 | return -1; 51 | } 52 | 53 | fseek(fd, 0, SEEK_END); 54 | size = ftell(fd); 55 | rewind(fd); 56 | 57 | ident = make_ident ( argv[1] ); 58 | 59 | printf ( "static const unsigned char __attribute__((section (\"._%s\"))) %s[] = {", ident, ident ); 60 | for ( total = 0; total < size; ) 61 | { 62 | if ( size - total < blksize ) blksize = size - total; 63 | if ( fread ( buf, 1, blksize, fd ) != blksize ) 64 | { 65 | fprintf ( stderr, "%s: file read error\n", argv[0] ); 66 | return -1; 67 | } 68 | for ( i = 0; i < blksize; i++ ) 69 | { 70 | if ( need_comma ) printf ( ", " ); 71 | else need_comma = 1; 72 | if ( ( total % 11 ) == 0 ) printf ( "\n\t" ); 73 | printf ( "0x%.2x", buf[i] ); 74 | total++; 75 | } 76 | } 77 | printf ( "\n};\n" ); 78 | 79 | fclose ( fd ); 80 | free ( ident ); 81 | 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /tools/find_chinese.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | import os 4 | 5 | allChineseWords = set({}) 6 | 7 | paths = ['../nyx/nyx_gui/frontend/', '../bdk/usb/'] 8 | for path in paths: 9 | for filename in os.listdir(path): 10 | if filename.endswith('.c'): 11 | with open(path + filename, encoding='utf-8') as file: 12 | content = file.read() 13 | ll = re.findall('[\u4e00-\u9fa5]', content) 14 | for w in ll: 15 | allChineseWords.add(w) 16 | 17 | allChineseWords.update(set(list("识别大气层侦安卓怀旧"))) 18 | wordList = list(allChineseWords) 19 | wordList.sort() 20 | for w in wordList: 21 | print(w, end="") 22 | print("\n") -------------------------------------------------------------------------------- /tools/fix_regs.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | def parse_defs(fname): 5 | f = open(fname, "r") 6 | lines = f.readlines() 7 | f.close() 8 | res = {} 9 | for l in lines: 10 | p = [str(_.strip()) for _ in l.strip().split(" ", 1)] 11 | res[int(p[1], 16)] = p[0] 12 | return res 13 | 14 | mc = parse_defs("mc.def") 15 | emc = parse_defs("emc.def") 16 | 17 | f = open(sys.argv[1], "r") 18 | buf = f.read() 19 | f.close() 20 | 21 | def fix(m): 22 | what = m.groups()[0] 23 | off = int(m.groups()[1], 16) 24 | if what == "MC": 25 | if off in mc: 26 | return "MC({0})".format(mc[off]) 27 | elif what == "EMC": 28 | if off in emc: 29 | return "EMC({0})".format(emc[off]) 30 | return "{0}(0x{1:X})".format(what, off) 31 | 32 | buf = re.sub(r'([A-Z]+)\(0x([0-9a-fA-F]+)\)', fix, buf) 33 | 34 | f = open(sys.argv[2], "w") 35 | f.write(buf) 36 | f.close() 37 | -------------------------------------------------------------------------------- /tools/lz/Makefile: -------------------------------------------------------------------------------- 1 | NATIVE_CC ?= gcc 2 | 3 | ifeq (, $(shell which $(NATIVE_CC) 2>/dev/null)) 4 | $(error "Native GCC is missing. Please install it first. If it's path is custom, set it with export NATIVE_CC=") 5 | endif 6 | 7 | .PHONY: all clean 8 | 9 | all: lz77 10 | @echo > /dev/null 11 | 12 | clean: 13 | @rm -f lz77 14 | 15 | lz77: lz.c lz77.c 16 | @$(NATIVE_CC) -o $@ lz.c lz77.c 17 | -------------------------------------------------------------------------------- /tools/lz/lz.h: -------------------------------------------------------------------------------- 1 | // 2 | // Name: lz.h 3 | // Author: Marcus Geelnard 4 | // Description: LZ77 coder/decoder interface. 5 | // Reentrant: Yes 6 | // ------------------------------------------------------------------------ 7 | // $ATH_LICENSE_NULL$ 8 | // Copyright (c) 2003-2006 Marcus Geelnard 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | // Marcus Geelnard 30 | // marcus.geelnard at home.se 31 | // 32 | 33 | // 34 | // This file has been altered from the original version. 35 | // 36 | 37 | #ifndef _lz_h_ 38 | #define _lz_h_ 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | 45 | /************************************************************************* 46 | * Function prototypes 47 | *************************************************************************/ 48 | 49 | int LZ_Compress( unsigned char *in, unsigned char *out, 50 | unsigned int insize ); 51 | int LZ_CompressFast( unsigned char *in, unsigned char *out, 52 | unsigned int insize, unsigned int *work ); 53 | int LZ_Uncompress( unsigned char *in, unsigned char *out, 54 | unsigned int insize ); 55 | 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _lz_h_ */ 62 | -------------------------------------------------------------------------------- /tools/lz/lz77.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 CTCaer 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "lz.h" 23 | 24 | char filename[1024]; 25 | 26 | int main(int argc, char *argv[]) 27 | { 28 | int nbytes; 29 | int filename_len; 30 | struct stat statbuf; 31 | FILE *in_file, *out_file; 32 | 33 | if(stat(argv[1], &statbuf)) 34 | goto error; 35 | 36 | if((in_file=fopen(argv[1], "rb")) == NULL) 37 | goto error; 38 | 39 | strcpy(filename, argv[1]); 40 | filename_len = strlen(filename); 41 | 42 | uint32_t in_size = statbuf.st_size; 43 | uint8_t *in_buf = (uint8_t *)malloc(in_size); 44 | 45 | uint32_t out_size = statbuf.st_size + 257; 46 | uint8_t *out_buf = (uint8_t *)malloc(out_size); 47 | 48 | if(!(in_buf && out_buf)) 49 | goto error; 50 | 51 | if(fread(in_buf, 1, in_size, in_file) != in_size) 52 | goto error; 53 | 54 | fclose(in_file); 55 | 56 | uint32_t *work = (uint32_t*)malloc(sizeof(uint32_t) * (in_size + 65536)); 57 | for (int i = 0; i < 2; i++) 58 | { 59 | uint32_t in_size_tmp; 60 | if (!i) 61 | { 62 | in_size_tmp = in_size / 2; 63 | strcpy(filename + filename_len, ".00.lz"); 64 | } 65 | else 66 | { 67 | in_size_tmp = in_size - (in_size / 2); 68 | strcpy(filename + filename_len, ".01.lz"); 69 | } 70 | 71 | if (work) 72 | nbytes = LZ_CompressFast(in_buf + (in_size / 2) * i, out_buf, in_size_tmp, work); 73 | else 74 | goto error; 75 | 76 | if (nbytes > out_size) 77 | goto error; 78 | 79 | if((out_file = fopen(filename,"wb")) == NULL) 80 | goto error; 81 | 82 | if (fwrite(out_buf, 1, nbytes, out_file) != nbytes) 83 | goto error; 84 | 85 | fclose(out_file); 86 | } 87 | 88 | return 0; 89 | 90 | error: 91 | fprintf(stderr, "Failed to compress: %s\n", argv[1]); 92 | exit(1); 93 | } 94 | -------------------------------------------------------------------------------- /tools/smmu_payload.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (c) 2018 balika011 3 | 4 | This program is free software; you can redistribute it and/or modify it 5 | under the terms and conditions of the GNU General Public License, 6 | version 2, as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope it will be useful, but WITHOUT 9 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program. If not, see . 15 | ''' 16 | 17 | from keystone import * 18 | 19 | CODE = b''' 20 | LDR X1, =0x70019010 21 | MOV X0, #0x1 22 | STR W0, [X1] 23 | 24 | loop: 25 | IC IALLUIS 26 | DSB ISH 27 | B loop 28 | MOV X0, #0x0 29 | STR W0, [X1] 30 | LDR X0, =0x4002B000 31 | BR X0 32 | ''' 33 | try: 34 | ks = Ks(KS_ARCH_ARM64, KS_MODE_LITTLE_ENDIAN) 35 | encoding, count = ks.asm(CODE, 0x0) 36 | print("%s = %s (number of statements: %u)" %(CODE, ', '.join([('0x%02x' % (x)) for x in encoding]), count)) 37 | except KsError as e: 38 | print("ERROR: %s" %e) --------------------------------------------------------------------------------