From d26036855c0cd61a05f003dd719cb119017b1f20 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 10 Oct 2023 18:15:43 +0800 Subject: [PATCH] ses_steps.c --- ses_step_topo.c | 3 ++ ses_steps.c | 101 +++++++++++++++++++++++++++++++++++++++++------- ses_utils.c | 2 +- 3 files changed, 92 insertions(+), 14 deletions(-) diff --git a/ses_step_topo.c b/ses_step_topo.c index 7cc05cc..6f68509 100644 --- a/ses_step_topo.c +++ b/ses_step_topo.c @@ -287,6 +287,9 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* } } + scf_loge("ctx->paths: %p, ctx->paths->size: %d\n", ctx->paths, ctx->paths->size); + scf_vector_clear(ctx->paths, ( void (*)(void*) )ses_path_free); + B = f->components[0]; el = f->elines[B->pins[SCF_EDA_Battery_POS]->lid]; path = NULL; diff --git a/ses_steps.c b/ses_steps.c index 4e75ddb..0ed9cb7 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -23,14 +23,17 @@ extern ses_step_t ses_step_va_balance; extern ses_step_t ses_step_output; -static ses_step_t* ses_steps[] = +static ses_step_t* ses_steps_0[] = { &ses_step_battery, &ses_step_dc_input, &ses_step_dc_diode, &ses_step_dc_transistor, +}; +static ses_step_t* ses_steps_1[] = +{ &ses_step_simplify, &ses_step_topo, @@ -41,41 +44,113 @@ static ses_step_t* ses_steps[] = &ses_step_jr, &ses_step_va, &ses_step_va_balance, +}; +static ses_step_t* ses_steps_2[] = +{ &ses_step_output, }; +static int __ses_steps_input(ScfEfunction* f, int64_t ns, int64_t i, ses_ctx_t* ctx) +{ + ses_step_t* s; + + int64_t j; + + for (j = 0; j < sizeof(ses_steps_0) / sizeof(ses_steps_0[0]); j++) { + s = ses_steps_0[j]; + + if (!s || !s->handler) + continue; + + int ret = s->handler(f, ns, i, ctx); + if (ret < 0) { + scf_loge("analysis step '%s' ret: %d\n", s->name, ret); + return ret; + } + } + + return 0; +} + +static int __ses_steps_output(ScfEfunction* f, int64_t ns, int64_t i, ses_ctx_t* ctx) +{ + ses_step_t* s; + + int64_t j; + + for (j = 0; j < sizeof(ses_steps_2) / sizeof(ses_steps_2[0]); j++) { + s = ses_steps_2[j]; + + if (!s || !s->handler) + continue; + + int ret = s->handler(f, ns, i, ctx); + if (ret < 0) { + scf_loge("analysis step '%s' ret: %d\n", s->name, ret); + return ret; + } + } + + return 0; +} + +static int __ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t i, ses_ctx_t* ctx) +{ + ses_step_t* s; + + int64_t j; + + for (j = 0; j < sizeof(ses_steps_1) / sizeof(ses_steps_1[0]); j++) { + s = ses_steps_1[j]; + + if (!s || !s->handler) + continue; + + int ret = s->handler(f, ns, i, ctx); + if (ret < 0) { + scf_loge("analysis step '%s' ret: %d\n", s->name, ret); + return ret; + } + } + + return 0; +} + int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count) { if (!f || ns <= 0 || count < 0) return -EINVAL; - ses_step_t* s; - ses_ctx_t* ctx = ses_ctx_alloc(); - + ses_ctx_t* ctx = ses_ctx_alloc(); if (!ctx) return -ENOMEM; int64_t i; - int64_t j; for (i = 0; i < count; i++) { - for (j = 0; j < sizeof(ses_steps) / sizeof(ses_steps[0]); j++) { - s = ses_steps[j]; + int ret = __ses_steps_input(f, ns, i, ctx); + if (ret < 0) + return ret; + + while (1) { + ret = __ses_steps_analyse(f, ns, i, ctx); - if (!s || !s->handler) + if (-EAGAIN == ret) continue; - int ret = s->handler(f, ns, i, ctx); - if (ret < 0) { - scf_loge("analysis step '%s' ret: %d\n", s->name, ret); + if (0 == ret) + break; - ses_ctx_free(ctx); + if (ret < 0) return ret; - } } + + ret = __ses_steps_output(f, ns, i, ctx); + if (ret < 0) + return ret; } ses_ctx_free(ctx); diff --git a/ses_utils.c b/ses_utils.c index bfa53a7..5fa1b51 100644 --- a/ses_utils.c +++ b/ses_utils.c @@ -435,7 +435,7 @@ void ses_ctx_free(ses_ctx_t* ctx) { if (ctx) { if (ctx->paths) { - scf_vector_clear(ctx->paths, ( void (*)(void*) )scf_vector_free); + scf_vector_clear(ctx->paths, ( void (*)(void*) )ses_path_free); scf_vector_free (ctx->paths); } -- 2.25.1