repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
Whisper | github_2023 | Const-me | c | ggml_compute_backward | static void ggml_compute_backward(struct ggml_context * ctx, struct ggml_tensor * tensor, bool inplace) {
struct ggml_tensor * src0 = tensor->src0;
struct ggml_tensor * src1 = tensor->src1;
switch (tensor->op) {
case GGML_OP_DUP:
{
if (src0->grad) {
s... | //////////////////////////////////////////////////////////////////////////////// | https://github.com/Const-me/Whisper/blob/306aadd1fce4b168cd38659236f4ba7c1603cebd/Whisper/source/ggml.c#L6484-L6726 | 306aadd1fce4b168cd38659236f4ba7c1603cebd |
Whisper | github_2023 | Const-me | c | ggml_graph_find | static bool ggml_graph_find(const struct ggml_cgraph * cgraph, const struct ggml_tensor * node) {
if (cgraph == NULL) {
return true;
}
for (int i = 0; i < cgraph->n_nodes; i++) {
if (cgraph->nodes[i] == node) {
return true;
}
}
return false;
} | // check if node is part of the graph | https://github.com/Const-me/Whisper/blob/306aadd1fce4b168cd38659236f4ba7c1603cebd/Whisper/source/ggml.c#L7442-L7454 | 306aadd1fce4b168cd38659236f4ba7c1603cebd |
Whisper | github_2023 | Const-me | c | ggml_opt_set_params | static void ggml_opt_set_params(int np, struct ggml_tensor * const ps[], const float * x) {
int i = 0;
for (int p = 0; p < np; ++p) {
const int ne = ggml_nelements(ps[p]) ;
// TODO: add function to set tensor from array
for (int j = 0; j < ne; ++j) {
ggml_set_f32_1d(ps[p], j,... | //////////////////////////////////////////////////////////////////////////////// | https://github.com/Const-me/Whisper/blob/306aadd1fce4b168cd38659236f4ba7c1603cebd/Whisper/source/ggml.c#L7585-L7594 | 306aadd1fce4b168cd38659236f4ba7c1603cebd |
Whisper | github_2023 | Const-me | c | ggml_opt_adam | static enum ggml_opt_result ggml_opt_adam(
struct ggml_context * ctx,
struct ggml_opt_params params,
struct ggml_tensor * f,
struct ggml_cgraph * gf,
struct ggml_cgraph * gb) {
assert(ggml_is_scalar(f));
gf->n_threads = params.n_threads;
gb->n_threads = params.n_thre... | //
// ADAM
//
// ref: https://arxiv.org/pdf/1412.6980.pdf
// | https://github.com/Const-me/Whisper/blob/306aadd1fce4b168cd38659236f4ba7c1603cebd/Whisper/source/ggml.c#L7624-L7794 | 306aadd1fce4b168cd38659236f4ba7c1603cebd |
Whisper | github_2023 | Const-me | c | ggml_cpu_has_avx | int ggml_cpu_has_avx(void) {
#if defined(__AVX__)
return 1;
#else
return 0;
#endif
} | //////////////////////////////////////////////////////////////////////////////// | https://github.com/Const-me/Whisper/blob/306aadd1fce4b168cd38659236f4ba7c1603cebd/Whisper/source/ggml.c#L8256-L8262 | 306aadd1fce4b168cd38659236f4ba7c1603cebd |
libxev | github_2023 | mitchellh | c | task_callback | void task_callback(xev_threadpool_task* t) {
job_t *job = container_of(t, job_t, pool_task);
job->done = true;
} | // This is the callback that is invoked when the task is being worked on. | https://github.com/mitchellh/libxev/blob/c6e8719a321088691829e2e4bf4d13eed5d4fb69/examples/threadpool.c#L22-L25 | c6e8719a321088691829e2e4bf4d13eed5d4fb69 |
LenovoLegionLinux | github_2023 | johnfanv2 | c | acpi_erax_dh | void acpi_erax_dh(acpi_handle object, void *data){
pr_info("sdfsdf\n");
} | /* ================================================ */
/* Trying to find memory region experiements */
/* ================================================ */
// experimental and currently not used! | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop-unused-snippets.c#L418-L420 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_acpi_get_ec_start | static int legion_acpi_get_ec_start(struct acpi_device *adev, phys_addr_t * mm_start_addr){
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_resource *resource;
//struct acpi_resource_address64 address;
acpi_status status;
int err;
unsigned long long erax_addr;
struct acpi_device_info *in... | /**
* Get the memory mapped start address of the memory of the embedded controller .
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop-unused-snippets.c#L455-L550 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | ideapad_acpi_add | static int ideapad_acpi_add(struct acpi_device *adev)
{
struct legion_private *priv = &_legion_priv;
int err;
phys_addr_t start_addr_ec;
pr_info("Loading platform/ACPI driver.\n");
if (!adev || eval_int(adev->handle, "_CFG", &cfg)){
err = -ENODEV;
return err;
}
pr_info("acpi device and _CFG successful.\n")... | ////////////
/*
* Platform driver from ideapad_acpi.c in linux kernel (modified)
* Use either that or ACPI driver.
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop-unused-snippets.c#L563-L589 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | eval_int | static int eval_int(acpi_handle handle, const char *name, unsigned long *res)
{
unsigned long long result;
acpi_status status;
status = acpi_evaluate_integer(handle, (char *)name, NULL, &result);
if (ACPI_FAILURE(status))
return -EIO;
*res = result;
return 0;
} | /* ================================= */
/* ACPI and WMI access */
/* ================================= */
// function from ideapad-laptop.c | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1354-L1366 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | exec_simple_method | static int exec_simple_method(acpi_handle handle, const char *name,
unsigned long arg)
{
acpi_status status =
acpi_execute_simple_method(handle, (char *)name, arg);
return ACPI_FAILURE(status) ? -EIO : 0;
} | // function from ideapad-laptop.c | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1369-L1376 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | exec_sbmc | static int exec_sbmc(acpi_handle handle, unsigned long arg)
{
// \_SB.PCI0.LPC0.EC0.VPC0.SBMC
return exec_simple_method(handle, "VPC0.SBMC", arg);
} | // function from ideapad-laptop.c | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1379-L1383 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | eval_gbmd | static int eval_gbmd(acpi_handle handle, unsigned long *res)
{
return eval_int(handle, "VPC0.GBMD", res);
} | //static int eval_qcho(acpi_handle handle, unsigned long *res)
//{
// // \_SB.PCI0.LPC0.EC0.QCHO
// return eval_int(handle, "QCHO", res);
//} | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1391-L1394 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | wmi_exec_ints | static int wmi_exec_ints(const char *guid, u8 instance, u32 method_id,
const struct acpi_buffer *params, u8 *res,
size_t ressize)
{
acpi_status status;
struct acpi_buffer out_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
status = wmi_evaluate_method(guid, instance, method_id, params,
&out_buffer);
retu... | //static int exec_ints(acpi_handle handle, const char *method_name,
// struct acpi_object_list *params, u8 *res, size_t ressize)
//{
// acpi_status status;
// struct acpi_buffer out_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
// status = acpi_evaluate_object(handle, (acpi_string)method_name, params,
// &out... | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1459-L1470 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | ecram_memoryio_init | static ssize_t ecram_memoryio_init(struct ecram_memoryio *ec_memoryio,
phys_addr_t physical_start,
phys_addr_t physical_ec_start, size_t size)
{
void *virtual_start = ioremap(physical_start, size);
if (!IS_ERR_OR_NULL(virtual_start)) {
ec_memoryio->virtual_start = virtual_start;
ec_memoryio->physic... | /**
* physical_start : corresponds to EC RAM 0 inside EC
* size: size of remapped region
*
* strong exception safety
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1760-L1781 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | ecram_memoryio_read | static ssize_t ecram_memoryio_read(const struct ecram_memoryio *ec_memoryio,
u16 ec_offset, u8 *value)
{
if (ec_offset < ec_memoryio->physical_ec_start) {
pr_info("Unexpected read at offset %d into EC RAM\n",
ec_offset);
return -1;
}
*value = *(ec_memoryio->virtual_start +
(ec_offset - ec_memoryio... | /* Read a byte from the EC RAM.
*
* Return status because of commong signature for alle
* methods to access EC RAM.
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1800-L1811 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | ecram_memoryio_write | static ssize_t ecram_memoryio_write(const struct ecram_memoryio *ec_memoryio,
u16 ec_offset, u8 value)
{
if (ec_offset < ec_memoryio->physical_ec_start) {
pr_info("Unexpected write at offset %d into EC RAM\n",
ec_offset);
return -1;
}
*(ec_memoryio->virtual_start +
(ec_offset - ec_memoryio->physica... | /* Write a byte to the EC RAM.
*
* Return status because of commong signature for alle
* methods to access EC RAM.
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1818-L1829 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | ecram_portio_read | static ssize_t ecram_portio_read(struct ecram_portio *ec_portio, u16 offset,
u8 *value)
{
mutex_lock(&ec_portio->io_port_mutex);
outb(0x2E, ECRAM_PORTIO_ADDR_PORT);
outb(0x11, ECRAM_PORTIO_DATA_PORT);
outb(0x2F, ECRAM_PORTIO_ADDR_PORT);
// TODO: no explicit cast between types seems to be sometimes
// done a... | /* Read a byte from the EC RAM.
*
* Return status because of commong signature for alle
* methods to access EC RAM.
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1899-L1923 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | ecram_portio_write | static ssize_t ecram_portio_write(struct ecram_portio *ec_portio, u16 offset,
u8 value)
{
mutex_lock(&ec_portio->io_port_mutex);
outb(0x2E, ECRAM_PORTIO_ADDR_PORT);
outb(0x11, ECRAM_PORTIO_DATA_PORT);
outb(0x2F, ECRAM_PORTIO_ADDR_PORT);
// TODO: no explicit cast between types seems to be sometimes
// done ... | /* Write a byte to the EC RAM.
*
* Return status because of commong signature for alle
* methods to access EC RAM.
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1930-L1956 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | ecram_read | static u8 ecram_read(struct ecram *ecram, u16 ecram_offset)
{
u8 value;
int err;
err = ecram_portio_read(&ecram->portio, ecram_offset, &value);
if (err)
pr_info("Error reading EC RAM at 0x%x.\n", ecram_offset);
return value;
} | /** Read from EC RAM
* ecram_offset address on the EC
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1994-L2003 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | read_ec_id | static u16 read_ec_id(struct ecram *ecram, const struct model_config *model)
{
u8 id1 = ecram_read(ecram, model->registers->ECHIPID1);
u8 id2 = ecram_read(ecram, model->registers->ECHIPID2);
return (id1 << 8) + id2;
} | /* =============================== */
/* Reads from EC */
/* =============================== */ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2024-L2030 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | fancurve_is_valid_min_temp | static bool fancurve_is_valid_min_temp(int min_temp)
{
return min_temp >= 0 && min_temp <= 127;
} | // validation functions | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2133-L2136 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | fancurve_set_speed_pwm | static bool fancurve_set_speed_pwm(struct fancurve *fancurve, int point_id,
int fan_id, int value)
{
u8 *speed;
if (!(point_id == 0 ? value == 0 : (value >= 0 && value <= 255))) {
pr_err("Value %d PWM not in allowed range to point with id %d",
value, point_id);
return false;
}
if (!(point_id < ... | // setters with validation
// - make hwmon implementation easier
// - keep fancurve valid, otherwise EC will not properly control fan | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2147-L2181 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | fancurve_set_accel | static bool fancurve_set_accel(struct fancurve *fancurve, int point_id,
int accel)
{
bool valid = accel >= 2 && accel <= 5;
if (valid)
fancurve->points[point_id].accel = accel;
return valid;
} | // TODO: remove { ... } from single line if body | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2225-L2233 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | ec_read_sensor_values | static int ec_read_sensor_values(struct ecram *ecram,
const struct model_config *model,
struct sensor_values *values)
{
values->fan1_target_rpm =
100 * ecram_read(ecram, model->registers->EXT_FAN1_TARGET_RPM);
values->fan2_target_rpm =
100 * ecram_read(ecram, model->registers->EXT_FAN2_TARGET_RPM);
va... | /* ============================= */
/* Sensor value reading/writing */
/* ============================= */ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2519-L2549 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | wmi_read_fanspeed | static ssize_t wmi_read_fanspeed(int fan_id, int *fanspeed_rpm)
{
int err;
unsigned long res;
struct acpi_buffer params;
params.length = 1;
params.pointer = &fan_id;
err = wmi_exec_int(WMI_GUID_LENOVO_FAN_METHOD, 0,
WMI_METHOD_ID_FAN_GETCURRENTFANSPEED, ¶ms, &res);
if (!err)
*fanspeed_rpm = res;
... | // fan_id: 0 or 1 | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2650-L2665 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | wmi_read_temperature | static ssize_t wmi_read_temperature(int sensor_id, int *temperature)
{
int err;
unsigned long res;
struct acpi_buffer params;
if (sensor_id == 0)
sensor_id = 0x03;
else if (sensor_id == 1)
sensor_id = 0x04;
else {
// TODO: use all correct error codes
return -EEXIST;
}
params.length = 1;
params.pointe... | //sensor_id: cpu = 0, gpu = 1 | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2668-L2693 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | wmi_read_fanspeed_gz | static ssize_t wmi_read_fanspeed_gz(int fan_id, int *fanspeed_rpm)
{
int err;
u32 method_id;
unsigned long res;
if (fan_id == 0)
method_id = WMI_METHOD_ID_GETFAN1SPEED;
else if (fan_id == 1)
method_id = WMI_METHOD_ID_GETFAN2SPEED;
else {
// TODO: use all correct error codes
return -EEXIST;
}
err = wmi_... | // fan_id: 0 or 1 | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2696-L2715 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | wmi_read_temperature_gz | static ssize_t wmi_read_temperature_gz(int sensor_id, int *temperature)
{
int err;
u32 method_id;
unsigned long res;
if (sensor_id == 0)
method_id = WMI_METHOD_ID_GETCPUTEMP;
else if (sensor_id == 1)
method_id = WMI_METHOD_ID_GETGPUTEMP;
else {
// TODO: use all correct error codes
return -EEXIST;
}
er... | //sensor_id: cpu = 0, gpu = 1 | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2718-L2738 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | wmi_read_fanspeed_other | static ssize_t wmi_read_fanspeed_other(int fan_id, int *fanspeed_rpm)
{
int err;
enum OtherMethodFeature featured_id;
int res;
if (fan_id == 0)
featured_id = OtherMethodFeature_FAN_SPEED_1;
else if (fan_id == 1)
featured_id = OtherMethodFeature_FAN_SPEED_2;
else {
// TODO: use all correct error codes
ret... | // fan_id: 0 or 1 | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2741-L2761 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | wmi_read_temperature_other | static ssize_t wmi_read_temperature_other(int sensor_id, int *temperature)
{
int err;
enum OtherMethodFeature featured_id;
int res;
if (sensor_id == 0)
featured_id = OtherMethodFeature_TEMP_CPU;
else if (sensor_id == 1)
featured_id = OtherMethodFeature_TEMP_GPU;
else {
// TODO: use all correct error codes
... | //sensor_id: cpu = 0, gpu = 1 | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2764-L2783 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | ec_read_fancurve_legion | static int ec_read_fancurve_legion(struct ecram *ecram,
const struct model_config *model,
struct fancurve *fancurve)
{
size_t i = 0;
fancurve->fan_speed_unit = FAN_SPEED_UNIT_RPM_HUNDRED;
for (i = 0; i < MAXFANCURVESIZE; ++i) {
struct fancurve_point *point = &fancurve->points[i];
point->speed1 =
... | /* Read the fan curve from the EC.
*
* In newer models (>=2022) there is an ACPI/WMI to read fan curve as
* a whole. So read/write fan table as a whole to use the
* same interface for both cases.
*
* It reads all points from EC memory, even if stored fancurve is smaller, so
* it can contain 0 entries.
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L2958-L3002 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | toggle_powermode | static void toggle_powermode(struct legion_private *priv)
{
int old_powermode;
int next_powermode;
read_powermode(priv, &old_powermode);
next_powermode = old_powermode == 0 ? 1 : 0;
write_powermode(priv, next_powermode);
mdelay(1500);
write_powermode(priv, old_powermode);
} | /**
* Shortly toggle powermode to a different mode
* and switch back, e.g. to reset fan curve.
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L3599-L3610 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_kbd_bl2_brightness_get | static ssize_t legion_kbd_bl2_brightness_get(struct legion_private *priv)
{
unsigned long state = 0;
int err;
err = wmi_exec_noarg_int(LEGION_WMI_GAMEZONE_GUID, 0,
WMI_METHOD_ID_GETKEYBOARDLIGHT, &state);
if (err)
return -EINVAL;
return state;
} | /* ============================= */
/* Keyboard backlight read/write */
/* ============================= */ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L3659-L3670 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | debugfs_ecmemory_show | static int debugfs_ecmemory_show(struct seq_file *s, void *unused)
{
struct legion_private *priv = s->private;
size_t offset;
for (offset = 0; offset < priv->conf->memoryio_size; ++offset) {
char value = ecram_read(&priv->ecram,
priv->conf->memoryio_physical_ec_start +
offset);
seq_write(s, &value, ... | /* ============================= */
/* debugfs interface */
/* ============================ */ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L3761-L3774 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | seq_file_print_with_error | static void seq_file_print_with_error(struct seq_file *s, const char *name,
ssize_t err, int value)
{
seq_printf(s, "%s error: %ld\n", name, err);
seq_printf(s, "%s: %d\n", name, value);
} | //TODO: make (almost) all methods static | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L3799-L3804 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | show_simple_wmi_attribute | static int show_simple_wmi_attribute(struct device *dev,
struct device_attribute *attr, char *buf,
const char *guid, u8 instance,
u32 method_id, bool invert,
unsigned long scale)
{
unsigned long state = 0;
int err;
struct legion_private *priv = dev_get_drvdata(dev);
mutex_lock(&... | /* ============================= */
/* sysfs interface */
/* ============================ */ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L3990-L4009 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | touchpad_show | static ssize_t touchpad_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
return show_simple_wmi_attribute(dev, attr, buf,
LEGION_WMI_GAMEZONE_GUID, 0,
WMI_METHOD_ID_GETTPSTATUS, true, 1);
} | // on newer models the touchpad feature in ideapad does not work anymore, so
// we need this | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L4196-L4202 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | cpumaxfrequency_show | static ssize_t cpumaxfrequency_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return show_simple_wmi_attribute(dev, attr, buf,
LEGION_WMI_GAMEZONE_GUID, 0,
WMI_METHOD_ID_GETCPUMAXFREQUENCY,
false, 1);
} | // TOOD: probably remove again because provided by other means; only useful for overclocking | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L4273-L4280 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | gpu_default_ppab_ctrgp_powerlimit_show | static ssize_t
gpu_default_ppab_ctrgp_powerlimit_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return show_simple_wmi_attribute(
dev, attr, buf, WMI_GUID_LENOVO_GPU_METHOD, 0,
WMI_METHOD_ID_GPU_GET_DEFAULT_PPAB_CTGP_POWERLIMIT, false, 1);
} | // TOOD: probably remove again because provided by other means; only useful for overclocking | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L4518-L4525 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | gpu_boost_clock_show | static ssize_t gpu_boost_clock_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return show_simple_wmi_attribute(dev, attr, buf,
WMI_GUID_LENOVO_GPU_METHOD, 0,
WMI_METHOD_ID_GPU_GET_BOOST_CLOCK,
false, 1);
} | // TOOD: probably remove again because provided by other means; only useful for overclocking | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L4549-L4556 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_wmi_notify | static void legion_wmi_notify(struct wmi_device *wdev, union acpi_object *data)
{
struct legion_wmi_private *wpriv;
struct legion_private *priv;
mutex_lock(&legion_shared_mutex);
priv = legion_shared;
if ((!priv) && (priv->loaded)) {
pr_info("Received WMI event while not initialized!\n");
goto unlock;
}
wp... | //static void legion_wmi_notify2(u32 value, void *context)
// {
// pr_info("WMI notify\n" );
// } | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L4742-L4775 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_wmi_init | static int legion_wmi_init(void)
{
return wmi_driver_register(&legion_wmi_driver);
} | //acpi_status status = wmi_install_notify_handler(LEGION_WMI_GAMEZONE_GUID,
// legion_wmi_notify2, NULL);
//if (ACPI_FAILURE(status)) {
// return -ENODEV;
//}
//return 0; | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L4855-L4858 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_platform_profile_notify | static void legion_platform_profile_notify(void)
{
if (!enable_platformprofile)
pr_info("Skipping platform_profile_notify because enable_platformprofile is false\n");
platform_profile_notify();
} | /* ============================= */
/* Platform profile */
/* ============================ */ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L4874-L4880 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | sensor_label_show | static ssize_t sensor_label_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int sensor_id = (to_sensor_dev_attr(attr))->index;
const char *label;
switch (sensor_id) {
case SENSOR_CPU_TEMP_ID:
label = "CPU Temperature\n";
break;
case SENSOR_GPU_TEMP_ID:
label = "GPU Temperature\n";
... | /* ============================= */
/* hwom interface */
/* ============================ */
// hw-mon interface
// todo: register_group or register_info?
// TODO: use one common function (like here) or one function per attribute? | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L4992-L5025 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | sensor_show | static ssize_t sensor_show(struct device *dev, struct device_attribute *devattr,
char *buf)
{
struct legion_private *priv = dev_get_drvdata(dev);
int sensor_id = (to_sensor_dev_attr(devattr))->index;
struct sensor_values values;
int outval;
int err = -EIO;
switch (sensor_id) {
case SENSOR_CPU_TEMP_ID:
e... | // TODO: use one common function (like here) or one function per attribute? | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L5028-L5075 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | pwm1_mode_store | static ssize_t pwm1_mode_store(struct device *dev,
struct device_attribute *devattr,
const char *buf, size_t count)
{
int value;
int is_maximumfanspeed;
int err;
struct legion_private *priv = dev_get_drvdata(dev);
err = kstrtoint(buf, 0, &value);
if (err) {
err = -1;
pr_info("Parsing hwmo... | // TODO: remove? or use WMI method? | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L5593-L5625 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | acpi_init | static int acpi_init(struct legion_private *priv, struct acpi_device *adev)
{
int err;
unsigned long cfg;
bool skip_acpi_sta_check;
struct device *dev = &priv->platform_device->dev;
priv->adev = adev;
if (!priv->adev) {
dev_info(dev, "Could not get ACPI handle\n");
goto err_acpi_init;
}
skip_acpi_sta_chec... | /* ACPI*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L5800-L5835 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_kbd_bl_led_cdev_brightness_get | static enum led_brightness
legion_kbd_bl_led_cdev_brightness_get(struct led_classdev *led_cdev)
{
struct legion_private *priv =
container_of(led_cdev, struct legion_private, kbd_bl.led);
return legion_kbd_bl_brightness_get(priv);
} | /* ============================= */
/* White Keyboard Backlight */
/* ============================ */
// In style of ideapad-driver and with code modified from ideapad-driver. | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L5842-L5849 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_kbd_bl_exit | static void legion_kbd_bl_exit(struct legion_private *priv)
{
if (!priv->kbd_bl.initialized)
return;
priv->kbd_bl.initialized = false;
led_classdev_unregister(&priv->kbd_bl.led);
} | /**
* Deinit keyboard backlight.
*
* Can also be called if init was not successful.
*
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L5906-L5914 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_wmi_cdev_brightness_get | static enum led_brightness
legion_wmi_cdev_brightness_get(struct led_classdev *led_cdev)
{
struct legion_private *priv =
container_of(led_cdev, struct legion_private, kbd_bl.led);
struct light *light_ins = container_of(led_cdev, struct light, led);
return legion_wmi_light_get(priv, light_ins->light_id,
li... | /* ============================= */
/* Additional light driver */
/* ============================ */ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L5920-L5930 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_light_exit | static void legion_light_exit(struct legion_private *priv,
struct light *light_ins)
{
if (!light_ins->initialized)
return;
light_ins->initialized = false;
led_classdev_unregister(&light_ins->led);
} | /**
* Deinit light.
*
* Can also be called if init was not successful.
*
*/ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L5992-L6001 | ae96a82adb879e729c5727c8769888b47ee1181f |
LenovoLegionLinux | github_2023 | johnfanv2 | c | legion_add | static int legion_add(struct platform_device *pdev)
{
struct legion_private *priv;
const struct dmi_system_id *dmi_sys;
int err;
u16 ec_read_id;
bool skip_ec_id_check;
bool is_ec_id_valid;
bool is_denied = true;
bool is_allowed = false;
bool do_load_by_list = false;
bool do_load = false;
//struct legion_priv... | /* ============================= */
/* Platform driver */
/* ============================ */ | https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L6007-L6210 | ae96a82adb879e729c5727c8769888b47ee1181f |
teddycloud | github_2023 | toniebox-reverse-engineering | c | open_append | FRESULT open_append (
FIL* fp, /* [OUT] File object to create */
const char* path /* [IN] File name to be opened */
)
{
FRESULT fr;
/* Opens an existing file. If not exist, creates a new file. */
fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS);
if (fr == FR_OK) {
/* Seek... | /*------------------------------------------------------------/
/ Open or create a file in append mode
/ (This function was sperseded by FA_OPEN_APPEND flag at FatFs R0.12a)
/------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/documents/res/app1.c#L6-L22 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | delete_node | FRESULT delete_node (
TCHAR* path, /* Path name buffer with the sub-directory to delete */
UINT sz_buff, /* Size of path name buffer (items) */
FILINFO* fno /* Name read buffer */
)
{
UINT i, j;
FRESULT fr;
DIR dir;
fr = f_opendir(&dir, path); /* Open the sub-directory to make it e... | /*------------------------------------------------------------/
/ Delete a sub-directory even if it contains any file
/-------------------------------------------------------------/
/ The delete_node() function is for R0.12+.
/ It works regardless of FF_FS_RPATH.
*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/documents/res/app2.c#L9-L49 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | test_contiguous_file | FRESULT test_contiguous_file (
FIL* fp, /* [IN] Open file object to be checked */
int* cont /* [OUT] 1:Contiguous, 0:Fragmented or zero-length */
)
{
DWORD clst, clsz, step;
FSIZE_t fsz;
FRESULT fr;
*cont = 0;
fr = f_rewind(fp); /* Validates and prepares the file */
... | /*----------------------------------------------------------------------/
/ Test if the file is contiguous /
/----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/documents/res/app5.c#L5-L38 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | disk_status | DSTATUS disk_status (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
DSTATUS stat;
int result;
switch (pdrv) {
case DEV_RAM :
result = RAM_disk_status();
// translate the reslut code here
return stat;
case DEV_MMC :
result = MMC_disk_status();
// translate the reslut code here
... | /*-----------------------------------------------------------------------*/
/* Get Drive Status */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/diskio.c#L23-L53 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | disk_initialize | DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
DSTATUS stat;
int result;
switch (pdrv) {
case DEV_RAM :
result = RAM_disk_initialize();
// translate the reslut code here
return stat;
case DEV_MMC :
result = MMC_disk_initialize();
// translate the reslut... | /*-----------------------------------------------------------------------*/
/* Inidialize a Drive */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/diskio.c#L61-L91 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | disk_read | DRESULT disk_read (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */
LBA_t sector, /* Start sector in LBA */
UINT count /* Number of sectors to read */
)
{
DRESULT res;
int result;
switch (pdrv) {
case DEV_RAM :
// translate the arguments here
... | /*-----------------------------------------------------------------------*/
/* Read Sector(s) */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/diskio.c#L99-L139 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | disk_ioctl | DRESULT disk_ioctl (
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
DRESULT res;
int result;
switch (pdrv) {
case DEV_RAM :
// Process of the command for the RAM drive
return res;
case DEV_MMC :
// Process of the c... | /*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/diskio.c#L198-L228 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | ld_word | static WORD ld_word (const BYTE* ptr) /* Load a 2-byte little-endian word */
{
WORD rv;
rv = ptr[1];
rv = rv << 8 | ptr[0];
return rv;
} | /*--------------------------------------------------------------------------
Module Private Functions
---------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/* Load/Store multi-byte word in the FAT structure ... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L618-L625 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | dbc_1st | static int dbc_1st (BYTE c)
{
#if FF_CODE_PAGE == 0 /* Variable code page */
if (DbcTbl && c >= DbcTbl[0]) {
if (c <= DbcTbl[1]) return 1; /* 1st byte range 1 */
if (c >= DbcTbl[2] && c <= DbcTbl[3]) return 1; /* 1st byte range 2 */
}
#elif FF_CODE_PAGE >= 900 /* DBCS fixed code page */
if (c >= DbcTbl[0]) ... | /* !FF_FS_READONLY */
/*-----------------------------------------------------------------------*/
/* String functions */
/*-----------------------------------------------------------------------*/
/* Test if the byte is DBC 1st byte */ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L692-L708 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | dbc_2nd | static int dbc_2nd (BYTE c)
{
#if FF_CODE_PAGE == 0 /* Variable code page */
if (DbcTbl && c >= DbcTbl[4]) {
if (c <= DbcTbl[5]) return 1; /* 2nd byte range 1 */
if (c >= DbcTbl[6] && c <= DbcTbl[7]) return 1; /* 2nd byte range 2 */
if (c >= DbcTbl[8] && c <= DbcTbl[9]) return 1; /* 2nd byte range 3 */
}
#... | /* Test if the byte is DBC 2nd byte */ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L712-L730 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tchar2uni | static DWORD tchar2uni ( /* Returns a character in UTF-16 encoding (>=0x10000 on surrogate pair, 0xFFFFFFFF on decode error) */
const TCHAR** str /* Pointer to pointer to TCHAR string in configured encoding */
)
{
DWORD uc;
const TCHAR *p = *str;
#if FF_LFN_UNICODE == 1 /* UTF-16 input */
WCHAR wc;
uc = *p++; ... | /* Get a Unicode code point from the TCHAR string in defined API encodeing */ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L736-L801 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | put_utf | static UINT put_utf ( /* Returns number of encoding units written (0:buffer overflow or wrong encoding) */
DWORD chr, /* UTF-16 encoded character (Surrogate pair if >=0x10000) */
TCHAR* buf, /* Output buffer */
UINT szb /* Size of the buffer */
)
{
#if FF_LFN_UNICODE == 1 /* UTF-16 output */
WCHAR hs, wc;
hs = (W... | /* Store a Unicode char in defined API encoding */ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L805-L886 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | lock_volume | static int lock_volume ( /* 1:Ok, 0:timeout */
FATFS* fs, /* Filesystem object to lock */
int syslock /* System lock required */
)
{
int rv;
#if FF_FS_LOCK
rv = ff_mutex_take(fs->ldrv); /* Lock the volume */
if (rv && syslock) { /* System lock reqiered? */
rv = ff_mutex_take(FF_VOLUMES); /* Lock the sy... | /*-----------------------------------------------------------------------*/
/* Request/Release grant to access the volume */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L895-L917 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | chk_share | static FRESULT chk_share ( /* Check if the file can be accessed */
DIR* dp, /* Directory object pointing the file to be checked */
int acc /* Desired access type (0:Read mode open, 1:Write mode open, 2:Delete or rename) */
)
{
UINT i, be;
/* Search open object table for the object */
be = 0;
for (i = 0; i < F... | /*-----------------------------------------------------------------------*/
/* File shareing control functions */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L945-L969 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | sync_fs | static FRESULT sync_fs ( /* Returns FR_OK or FR_DISK_ERR */
FATFS* fs /* Filesystem object */
)
{
FRESULT res;
res = sync_window(fs);
if (res == FR_OK) {
if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { /* FAT32: Update FSInfo sector if needed */
/* Create FSInfo structure */
memset(fs->win, 0, sizeof... | /*-----------------------------------------------------------------------*/
/* Synchronize filesystem and data on the storage */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1108-L1134 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | clst2sect | static LBA_t clst2sect ( /* !=0:Sector number, 0:Failed (invalid cluster#) */
FATFS* fs, /* Filesystem object */
DWORD clst /* Cluster# to be converted */
)
{
clst -= 2; /* Cluster number is origin from 2 */
if (clst >= fs->n_fatent - 2) return 0; /* Is it invalid cluster number? */
return fs->database + (LBA_... | /*-----------------------------------------------------------------------*/
/* Get physical sector number from cluster number */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1144-L1152 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | get_fat | static DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x7FFFFFFF:Cluster status */
FFOBJID* obj, /* Corresponding object */
DWORD clst /* Cluster number to get the value */
)
{
UINT wc, bc;
DWORD val;
FATFS *fs = obj->fs;
if (clst < 2 || clst >= fs->n_fatent) { /* Check if in valid range */
... | /*-----------------------------------------------------------------------*/
/* FAT access - Read value of an FAT entry */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1161-L1229 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | put_fat | static FRESULT put_fat ( /* FR_OK(0):succeeded, !=0:error */
FATFS* fs, /* Corresponding filesystem object */
DWORD clst, /* FAT index number (cluster number) to be changed */
DWORD val /* New value to be set to the entry */
)
{
UINT bc;
BYTE *p;
FRESULT res = FR_INT_ERR;
if (clst >= 2 && clst < fs->n_faten... | /*-----------------------------------------------------------------------*/
/* FAT access - Change value of an FAT entry */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1239-L1288 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | find_bitmap | static DWORD find_bitmap ( /* 0:Not found, 2..:Cluster block found, 0xFFFFFFFF:Disk error */
FATFS* fs, /* Filesystem object */
DWORD clst, /* Cluster number to scan from */
DWORD ncl /* Number of contiguous clusters to find (1..) */
)
{
BYTE bm, bv;
UINT i;
DWORD val, scl, ctr;
clst -= 2; /* The first bit in ... | /*-----------------------------------------------------------------------*/
/* exFAT: Accessing FAT and Allocation Bitmap */
/*-----------------------------------------------------------------------*/
/*--------------------------------------*/
/* Find a contiguous free cluster block */
/*----... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1304-L1337 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | change_bitmap | static FRESULT change_bitmap (
FATFS* fs, /* Filesystem object */
DWORD clst, /* Cluster number to change from */
DWORD ncl, /* Number of clusters to be changed */
int bv /* bit value to be set (0 or 1) */
)
{
BYTE bm;
UINT i;
LBA_t sect;
clst -= 2; /* The first bit corresponds to cluster #2 */
sect = fs->b... | /*----------------------------------------*/
/* Set/Clear a block of allocation bitmap */
/*----------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1344-L1373 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | fill_first_frag | static FRESULT fill_first_frag (
FFOBJID* obj /* Pointer to the corresponding object */
)
{
FRESULT res;
DWORD cl, n;
if (obj->stat == 3) { /* Has the object been changed 'fragmented' in this session? */
for (cl = obj->sclust, n = obj->n_cont; n; cl++, n--) { /* Create cluster chain on the FAT */
res = put_f... | /*---------------------------------------------*/
/* Fill the first fragment of the FAT chain */
/*---------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1380-L1396 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | fill_last_frag | static FRESULT fill_last_frag (
FFOBJID* obj, /* Pointer to the corresponding object */
DWORD lcl, /* Last cluster of the fragment */
DWORD term /* Value to set the last FAT entry */
)
{
FRESULT res;
while (obj->n_frag > 0) { /* Create the chain of last fragment */
res = put_fat(obj->fs, lcl - obj->n_frag + ... | /*---------------------------------------------*/
/* Fill the last fragment of the FAT chain */
/*---------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1403-L1418 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | remove_chain | static FRESULT remove_chain ( /* FR_OK(0):succeeded, !=0:error */
FFOBJID* obj, /* Corresponding object */
DWORD clst, /* Cluster to remove a chain from */
DWORD pclst /* Previous cluster of clst (0 if entire chain) */
)
{
FRESULT res = FR_OK;
DWORD nxt;
FATFS *fs = obj->fs;
#if FF_FS_EXFAT || FF_USE_TRIM
D... | /*-----------------------------------------------------------------------*/
/* FAT handling - Remove a cluster chain */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1429-L1515 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | create_chain | static DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */
FFOBJID* obj, /* Corresponding object */
DWORD clst /* Cluster# to stretch, 0:Create a new chain */
)
{
DWORD cs, ncl, scl;
FRESULT res;
FATFS *fs = obj->fs;
if (clst == 0) { /* Create a new chain *... | /*-----------------------------------------------------------------------*/
/* FAT handling - Stretch a chain or Create a new chain */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1524-L1615 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | clmt_clust | static DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */
FIL* fp, /* Pointer to the file object */
FSIZE_t ofs /* File offset to be converted to cluster# */
)
{
DWORD cl, ncl;
DWORD *tbl;
FATFS *fs = fp->obj.fs;
tbl = fp->cltbl + 1; /* Top of CLMT */
cl = (DWORD)(ofs / SS(fs) / fs->csize); /* Cluster ord... | /*-----------------------------------------------------------------------*/
/* FAT handling - Convert offset into cluster with link map table */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1627-L1646 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | dir_sdi | static FRESULT dir_sdi ( /* FR_OK(0):succeeded, !=0:error */
DIR* dp, /* Pointer to directory object */
DWORD ofs /* Offset of directory table */
)
{
DWORD csz, clst;
FATFS *fs = dp->obj.fs;
if (ofs >= (DWORD)((FF_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR) || ofs % SZDIRE) { /* Check range of... | /* !FF_FS_READONLY */
/*-----------------------------------------------------------------------*/
/* Directory handling - Set directory index */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1697-L1736 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | dir_next | static FRESULT dir_next ( /* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */
DIR* dp, /* Pointer to the directory object */
int stretch /* 0: Do not stretch table, 1: Stretch table if needed */
)
{
DWORD ofs, clst;
FATFS *fs = dp->obj.fs;
ofs = dp->dptr + SZDIRE; /* Next entry *... | /*-----------------------------------------------------------------------*/
/* Directory handling - Move directory table index next */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1745-L1796 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | ld_clust | static DWORD ld_clust ( /* Returns the top cluster value of the SFN entry */
FATFS* fs, /* Pointer to the fs object */
const BYTE* dir /* Pointer to the key entry */
)
{
DWORD cl;
cl = ld_word(dir + DIR_FstClusLO);
if (fs->fs_type == FS_FAT32) {
cl |= (DWORD)ld_word(dir + DIR_FstClusHI) << 16;
}
return cl... | /* !FF_FS_READONLY */
/*-----------------------------------------------------------------------*/
/* FAT: Directory handling - Load/Store start cluster number */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1848-L1861 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | cmp_lfn | static int cmp_lfn ( /* 1:matched, 0:not matched */
const WCHAR* lfnbuf, /* Pointer to the LFN working buffer to be compared */
BYTE* dir /* Pointer to the directory entry containing the part of LFN */
)
{
UINT i, s;
WCHAR wc, uc;
if (ld_word(dir + LDIR_FstClusLO) != 0) return 0; /* Check LDIR_FstClusLO */
... | /*--------------------------------------------------------*/
/* FAT-LFN: Compare a part of file name with an LFN entry */
/*--------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1885-L1913 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | pick_lfn | static int pick_lfn ( /* 1:succeeded, 0:buffer overflow or invalid LFN entry */
WCHAR* lfnbuf, /* Pointer to the LFN working buffer */
BYTE* dir /* Pointer to the LFN entry */
)
{
UINT i, s;
WCHAR wc, uc;
if (ld_word(dir + LDIR_FstClusLO) != 0) return 0; /* Check LDIR_FstClusLO is 0 */
i = ((dir[LDIR_Ord] &... | /*-----------------------------------------------------*/
/* FAT-LFN: Pick a part of file name from an LFN entry */
/*-----------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1921-L1950 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | put_lfn | static void put_lfn (
const WCHAR* lfn, /* Pointer to the LFN */
BYTE* dir, /* Pointer to the LFN entry to be created */
BYTE ord, /* LFN order (1-20) */
BYTE sum /* Checksum of the corresponding SFN */
)
{
UINT i, s;
WCHAR wc;
dir[LDIR_Chksum] = sum; /* Set checksum */
dir[LDIR_Attr] = AM_LFN; /* Se... | /*-----------------------------------------*/
/* FAT-LFN: Create an entry of LFN entries */
/*-----------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1959-L1984 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | gen_numname | static void gen_numname (
BYTE* dst, /* Pointer to the buffer to store numbered SFN */
const BYTE* src, /* Pointer to SFN in directory form */
const WCHAR* lfn, /* Pointer to LFN */
UINT seq /* Sequence number */
)
{
BYTE ns[8], c;
UINT i, j;
WCHAR wc;
DWORD sreg;
memcpy(dst, src, 11); /* Prepare the SFN... | /*-----------------------------------------------------------------------*/
/* FAT-LFN: Create a Numbered SFN */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L1996-L2043 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | sum_sfn | static BYTE sum_sfn (
const BYTE* dir /* Pointer to the SFN entry */
)
{
BYTE sum = 0;
UINT n = 11;
do {
sum = (sum >> 1) + (sum << 7) + *dir++;
} while (--n);
return sum;
} | /*-----------------------------------------------------------------------*/
/* FAT-LFN: Calculate checksum of an SFN entry */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2053-L2064 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | xdir_sum | static WORD xdir_sum ( /* Get checksum of the directoly entry block */
const BYTE* dir /* Directory entry block to be calculated */
)
{
UINT i, szblk;
WORD sum;
szblk = (dir[XDIR_NumSec] + 1) * SZDIRE; /* Number of bytes of the entry block */
for (i = sum = 0; i < szblk; i++) {
if (i == XDIR_SetSum) { /* Skip... | /*-----------------------------------------------------------------------*/
/* exFAT: Checksum */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2075-L2092 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | load_xdir | static FRESULT load_xdir ( /* FR_INT_ERR: invalid entry block */
DIR* dp /* Reading directory object pointing top of the entry block to load */
)
{
FRESULT res;
UINT i, sz_ent;
BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory directory entry block 85+C0+C1s */
/* Load file directory entry */
res... | /*------------------------------------*/
/* exFAT: Get a directory entry block */
/*------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2130-L2174 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | init_alloc_info | static void init_alloc_info (
FATFS* fs, /* Filesystem object */
FFOBJID* obj /* Object allocation information to be initialized */
)
{
obj->sclust = ld_dword(fs->dirbuf + XDIR_FstClus); /* Start cluster */
obj->objsize = ld_qword(fs->dirbuf + XDIR_FileSize); /* Size */
obj->stat = fs->dirbuf[XDIR_GenFlags] & 2;... | /*------------------------------------------------------------------*/
/* exFAT: Initialize object allocation info with loaded entry block */
/*------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2181-L2190 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | load_obj_xdir | static FRESULT load_obj_xdir (
DIR* dp, /* Blank directory object to be used to access containing directory */
const FFOBJID* obj /* Object with its containing directory information */
)
{
FRESULT res;
/* Open object containing directory */
dp->obj.fs = obj->fs;
dp->obj.sclust = obj->c_scl;
dp->obj.stat = (BY... | /*------------------------------------------------*/
/* exFAT: Load the object's directory entry block */
/*------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2199-L2219 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | store_xdir | static FRESULT store_xdir (
DIR* dp /* Pointer to the directory object */
)
{
FRESULT res;
UINT nent;
BYTE *dirb = dp->obj.fs->dirbuf; /* Pointer to the directory entry block 85+C0+C1s */
/* Create set sum */
st_word(dirb + XDIR_SetSum, xdir_sum(dirb));
nent = dirb[XDIR_NumSec] + 1;
/* Store the directory ... | /*----------------------------------------*/
/* exFAT: Store the directory entry block */
/*----------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2228-L2252 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | create_xdir | static void create_xdir (
BYTE* dirb, /* Pointer to the directory entry block buffer */
const WCHAR* lfn /* Pointer to the object name */
)
{
UINT i;
BYTE nc1, nlen;
WCHAR wc;
/* Create file-directory and stream-extension entry */
memset(dirb, 0, 2 * SZDIRE);
dirb[0 * SZDIRE + XDIR_Type] = ET_FILEDIR;
dirb... | /*-------------------------------------------*/
/* exFAT: Create a new directory entry block */
/*-------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2260-L2291 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | dir_find | static FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */
DIR* dp /* Pointer to the directory object with the file name */
)
{
FRESULT res;
FATFS *fs = dp->obj.fs;
BYTE c;
#if FF_USE_LFN
BYTE a, ord, sum;
#endif
res = dir_sdi(dp, 0); /* Rewind directory object */
if (res != FR_OK) return res;
#if FF_F... | /* FF_FS_MINIMIZE <= 1 || FF_USE_LABEL || FF_FS_RPATH >= 2 */
/*-----------------------------------------------------------------------*/
/* Directory handling - Find an object in the directory */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2384-L2455 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | dir_register | static FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too many SFN collision, FR_DISK_ERR:disk error */
DIR* dp /* Target directory with object name to be created */
)
{
FRESULT res;
FATFS *fs = dp->obj.fs;
#if FF_USE_LFN /* LFN configuration */
UINT n, len, n_ent;
BYTE sn[12], sum;
... | /*-----------------------------------------------------------------------*/
/* Register an object to the directory */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2465-L2560 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | dir_remove | static FRESULT dir_remove ( /* FR_OK:Succeeded, FR_DISK_ERR:A disk error */
DIR* dp /* Directory object pointing the entry to be removed */
)
{
FRESULT res;
FATFS *fs = dp->obj.fs;
#if FF_USE_LFN /* LFN configuration */
DWORD last = dp->dptr;
res = (dp->blk_ofs == 0xFFFFFFFF) ? FR_OK : dir_sdi(dp, dp->blk_of... | /*-----------------------------------------------------------------------*/
/* Remove an object from the directory */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2571-L2606 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | get_fileinfo | static void get_fileinfo (
DIR* dp, /* Pointer to the directory object */
FILINFO* fno /* Pointer to the file information to be filled */
)
{
UINT si, di;
#if FF_USE_LFN
BYTE lcf;
WCHAR wc, hs;
FATFS *fs = dp->obj.fs;
UINT nw;
#else
TCHAR c;
#endif
fno->fname[0] = 0; /* Invaidate file info */
if (dp->s... | /*-----------------------------------------------------------------------*/
/* Get file information from directory entry */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2617-L2748 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | create_name | static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not create */
DIR* dp, /* Pointer to the directory object */
const TCHAR** path /* Pointer to pointer to the segment in the path string */
)
{
#if FF_USE_LFN /* LFN configuration */
BYTE b, cf;
WCHAR wc;
WCHAR *lfn;
const TCHAR* p;
... | /* FF_USE_FIND && FF_FS_MINIMIZE <= 1 */
/*-----------------------------------------------------------------------*/
/* Pick a top segment and create the object name in directory form */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L2847-L3042 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | follow_path | static FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */
DIR* dp, /* Directory object to return last directory and found object */
const TCHAR* path /* Full-path string to find a file or directory */
)
{
FRESULT res;
BYTE ns;
FATFS *fs = dp->obj.fs;
#if FF_FS_RPATH != 0
if (!IsSeparator(*p... | /*-----------------------------------------------------------------------*/
/* Follow a file path */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L3051-L3129 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | get_ldnumber | static int get_ldnumber ( /* Returns logical drive number (-1:invalid drive number or null pointer) */
const TCHAR** path /* Pointer to pointer to the path name */
)
{
const TCHAR *tp;
const TCHAR *tt;
TCHAR tc;
int i;
int vol = -1;
#if FF_STR_VOLUME_ID /* Find string volume ID */
const char *sp;
char c;
#end... | /*-----------------------------------------------------------------------*/
/* Get logical drive number from path name */
/*-----------------------------------------------------------------------*/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L3138-L3208 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | crc32 | static DWORD crc32 ( /* Returns next CRC value */
DWORD crc, /* Current CRC value */
BYTE d /* A byte to be processed */
)
{
BYTE b;
for (b = 1; b; b <<= 1) {
crc ^= (d & b) ? 1 : 0;
crc = (crc & 1) ? crc >> 1 ^ 0xEDB88320 : crc >> 1;
}
return crc;
} | /* Calculate CRC32 in byte-by-byte */ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L3221-L3234 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.