GCC Code Coverage Report


Directory: ./
File: boot/FPPINIT.h
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 2 4 50.0%
Functions: 1 2 50.0%
Branches: 15 68 22.1%

Line Branch Exec Source
1 /*
2 * This file is part of the Falcon Player (FPP) and is Copyright (C)
3 * 2013-2024 by the Falcon Player Developers.
4 *
5 * The Falcon Player (FPP) is free software, and is covered under
6 * multiple Open Source licenses. Please see the included 'LICENSES'
7 * file for descriptions of what files are covered by each license.
8 *
9 * This source file is covered under the LGPL v2.1 as described in the
10 * included LICENSE.LGPL file.
11 */
12
13 #pragma once
14
15 #include <string>
16
17 #include "common_mini.h"
18
19 #include "fpp-json-fwd.h"
20
21 #ifdef PLATFORM_BB64
22 inline const std::string SD_CARD_DEVICE = "/dev/mmcblk1";
23 #else
24 inline const std::string SD_CARD_DEVICE = "/dev/mmcblk0";
25 #endif
26
27 #ifdef PLATFORM_PI
28 inline const std::string I2C_DEV = "/dev/i2c-1";
29 #else
30 inline const std::string I2C_DEV = "/dev/i2c-2";
31 #endif
32
33 // $FPP_MEDIA_DIR, defaulting to /home/fpp/media (see getRawMediaDir()).
34 inline const std::string FPP_MEDIA_DIR = getRawMediaDir();
35
36 // ---------------------------------------------------------------------------
37 // Shared utilities (defined in FPPINIT.cpp)
38 // ---------------------------------------------------------------------------
39 void exec(const std::string& cmd);
40 int execbg(const std::string& cmd);
41 std::string execAndReturn(const std::string& cmd);
42 // True if s is non-empty and only [A-Za-z0-9._/+-], i.e. safe to splice
43 // unquoted into a shell command. For settings-file values used that way.
44 bool isShellSafeWord(const std::string& s);
45 bool LoadJsonFromString(const std::string& str, Json::Value& root);
46
47 // Require the parsed root to be the shape the caller expects. A mismatch
48 // yields an empty value of the expected shape and returns false, so callers
49 // that ignore the return value iterate over nothing instead of aborting.
50 enum class JsonRoot {
51 Object,
52 Array
53 };
54 bool LoadJsonFromString(const std::string& str, Json::Value& root, JsonRoot expected);
55
56 std::string SaveJsonToString(const Json::Value& root);
57 void modprobe(const char* mod);
58
59 #ifdef PLATFORM_PI
60 1 inline bool isPi5() {
61
15/60
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 1 times.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 1 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 1 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
5 return startsWith(GetFileContents("/proc/device-tree/model"), "Raspberry Pi 5") || startsWith(GetFileContents("/proc/device-tree/model"), "Raspberry Pi Compute Module 5");
62 }
63 ✗ inline bool isPiZero2W() {
64 ✗ return contains(GetFileContents("/proc/device-tree/model"), "Raspberry Pi Zero 2 W");
65 }
66 #endif
67
68 // ---------------------------------------------------------------------------
69 // Configuration / system setup (defined in FPPINIT_Config.cpp)
70 // ---------------------------------------------------------------------------
71 void DetectCape();
72 void checkSSHKeys();
73 void handleBootPartition();
74 void checkHostName();
75 void runScripts(const std::string tp, bool userBefore = true);
76 void checkFSTAB();
77 void createDirectories();
78 void setupApache();
79 void handleBootActions();
80 void configureBBB();
81 // captureDefaults=true only from boot, while sysfs still holds the device tree values
82 void applyThermalSettings(bool captureDefaults = false);
83 void resetThermalSettings();
84 // Force each fan on and read its tachometer, recording which fans actually
85 // report RPM so fppd can suppress the display for absent/dead fans. Boot only.
86 void probeFanPresence();
87 void setFileOwnership();
88 bool checkUnpartitionedSpace();
89 void resizeRootFS();
90 void setupTimezone();
91 void cleanupChromiumFiles();
92 void setupKiosk(bool force = false);
93 void checkInstallKiosk();
94 void installKiosk();
95 void checkInstallPackages();
96 void checkConfigMigrations();
97 void migrateRemoteCommands();
98 void migrateLegacyFppMode();
99 void startZRAMSwap();
100 void startDiskSwap();
101 void setupChannelOutputs();
102 void setupPiRTCConfig(bool rebootIfChanged = true);
103 void setupHDMICECConfig(bool rebootIfChanged = true);
104 void setupWifiAntennaConfig(bool rebootIfChanged = true);
105 void setup16KPageKernel(bool rebootIfChanged = true);
106 void handleRebootActions();
107
108 // ---------------------------------------------------------------------------
109 // Networking (defined in FPPINIT_Network.cpp)
110 // ---------------------------------------------------------------------------
111 std::string FindTetherWIFIAdapater();
112 void setupNetwork(bool fullReload = false);
113 void consumePendingDhcpLeaseReset();
114 void handleBootDelay();
115 void handleTimeSyncWait();
116 void checkWLANInterface();
117 // allowUsbRecovery: permit one USB re-enumeration of an adapter that came up
118 // dead. Boot path only -- the networkd-dispatcher-driven tether callers must
119 // never set it, since a reset causes the carrier change that re-invokes them.
120 bool waitForInterfacesUp(int timeOut, bool allowUsbRecovery = false);
121 // True once a wedged USB network adapter has caused a reboot to be queued. The
122 // boot is being thrown away, so callers should stop doing network setup work.
123 bool usbWedgeRebootPending();
124 void announceIPAddresses();
125 // Turn off 802.11 power saving on all wireless interfaces.
126 void disableWLANPowerManagement();
127 void maybeEnableTethering();
128 void detectNetworkModules();
129 void removeDummyInterface();
130
131 // ---------------------------------------------------------------------------
132 // Audio (defined in FPPINIT_Audio.cpp)
133 // ---------------------------------------------------------------------------
134 void setupAudio();
135