MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_fdt_bootargs_select

Function rt_fdt_bootargs_select

components/drivers/ofw/fdt.c:802–849  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

800}
801
802rt_err_t rt_fdt_bootargs_select(const char *key, int index, const char **out_result)
803{
804 rt_err_t err;
805
806 if (key && index >= 0 && out_result)
807 {
808 int offset = fdt_path_offset(_fdt, "/chosen");
809
810 if (offset >= 0)
811 {
812 int len, key_len = rt_strlen(key);
813 const char *bootargs = fdt_getprop(_fdt, offset, "bootargs", &len), *end;
814
815 end = bootargs + len;
816 err = -RT_EEMPTY;
817
818 for (int i = 0; bootargs < end; ++i)
819 {
820 bootargs = rt_strstr(bootargs, key);
821
822 if (!bootargs)
823 {
824 break;
825 }
826
827 bootargs += key_len;
828
829 if (i == index)
830 {
831 *out_result = bootargs;
832
833 err = -RT_EOK;
834 break;
835 }
836 }
837 }
838 else
839 {
840 err = -RT_ERROR;
841 }
842 }
843 else
844 {
845 err = -RT_EINVAL;
846 }
847
848 return err;
849}
850
851static void system_node_init_flag(struct rt_ofw_node *np)
852{

Callers

nothing calls this directly

Calls 4

rt_strlenFunction · 0.85
rt_strstrFunction · 0.85
fdt_path_offsetFunction · 0.50
fdt_getpropFunction · 0.50

Tested by

no test coverage detected