MCPcopy Create free account
hub / github.com/F-Stack/f-stack / main

Function main

freebsd/contrib/octeon-sdk/cvmx-app-init-linux.c:320–446  ·  view source on GitHub ↗

* Main entrypoint of the application. Here we setup shared * memory and fork processes for each cpu. This simulates the * normal simple executive environment of one process per * cpu core. * * @param argc Number of command line arguments * @param argv The command line arguments * @return Return value for the process */

Source from the content-addressed store, hash-verified

318 * @return Return value for the process
319 */
320int main(int argc, const char *argv[])
321{
322 CVMX_SHARED static cvmx_spinlock_t mask_lock = CVMX_SPINLOCK_UNLOCKED_INITIALIZER;
323 CVMX_SHARED static int32_t pending_fork;
324 unsigned long cpumask;
325 unsigned long cpu;
326 int firstcpu = 0;
327 int firstcore = 0;
328
329 cvmx_linux_enable_xkphys_access(0);
330 cvmx_sysinfo_linux_userspace_initialize();
331
332 if (sizeof(void*) == 4)
333 {
334 if (linux_mem32_min)
335 setup_reserve32();
336 else
337 {
338 printf("\nFailed to access 32bit shared memory region. Most likely the Kernel\n"
339 "has not been configured for 32bit shared memory access. Check the\n"
340 "kernel configuration.\n"
341 "Aborting...\n\n");
342 exit(-1);
343 }
344 }
345
346 setup_cvmx_shared();
347 cvmx_bootmem_init(cvmx_sysinfo_get()->phy_mem_desc_addr);
348
349 /* Check to make sure the Chip version matches the configured version */
350 octeon_model_version_check(cvmx_get_proc_id());
351
352 /* Initialize configuration to set bpid, pkind, pko_port for all the
353 available ports connected. */
354 __cvmx_helper_cfg_init();
355
356 /* Get the list of logical cpus we should run on */
357 if (sched_getaffinity(0, sizeof(cpumask), (cpu_set_t*)&cpumask))
358 {
359 perror("sched_getaffinity failed");
360 exit(errno);
361 }
362
363 cvmx_sysinfo_t *system_info = cvmx_sysinfo_get();
364
365 cvmx_atomic_set32(&pending_fork, 1);
366
367 /* Get the lowest logical cpu */
368 firstcore = ffsl(cpumask) - 1;
369 cpumask ^= (1ull<<(firstcore));
370 while (1)
371 {
372 if (cpumask == 0)
373 {
374 cpu = firstcore;
375 firstcpu = 1;
376 break;
377 }

Callers

nothing calls this directly

Calls 15

setup_reserve32Function · 0.85
setup_cvmx_sharedFunction · 0.85
cvmx_bootmem_initFunction · 0.85
cvmx_sysinfo_getFunction · 0.85
cvmx_get_proc_idFunction · 0.85
__cvmx_helper_cfg_initFunction · 0.85
cvmx_atomic_set32Function · 0.85
cvmx_atomic_add32Function · 0.85
cvmx_spinlock_lockFunction · 0.85

Tested by

no test coverage detected