Check-in [5f36b15924]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Changed more C-Style Casts
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5f36b15924c9d9589ba6c5fac8ab0ca79c19bf7c
User & Date: maxi 2018-11-12 12:56:58
Context
2018-11-13
06:34
fixed bugs in c++-style casts check-in: dc202cee4b user: maxi tags: trunk
06:32
merged trunk into descriptor check-in: 0a2b15c728 user: maxi tags: descriptor
2018-11-12
12:56
Changed more C-Style Casts check-in: 5f36b15924 user: maxi tags: trunk
2018-11-11
20:31
changed typecasts in acpi_utils.hpp to c++style casts check-in: b14aea8e31 user: maxi tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/acpi/wrappers.cpp.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
madt_wrapper::madt_wrapper() {}
bool madt_wrapper::is_out_of_bounds(size_t _offset)
{
    return _offset > (madt_ptr->h.Length - sizeof(SDT::generic_sdt));
}

SDT::GENERIC_MADT_ENTRY *madt_wrapper::get_current_entry(){
    return (SDT::GENERIC_MADT_ENTRY *)(&madt_ptr->Entries[offset]);
}

SDT::GENERIC_MADT_ENTRY *madt_wrapper::get_next_entry()
{
    if (is_out_of_bounds(offset))
        offset = 0;
    offset += get_current_entry()->RecordLength;
................................................................................
    return nullptr;
}

void madt_wrapper::reset_entry_pointer() { offset = 0; }

inline void sdt_wrapper::set_rsdp(void *ptr)
{
    SDT::RSDP *rsdpptr = (SDT::RSDP *)ptr;
    acpi_version = rsdpptr->Revision;
    if (UTILS::is_rsdp_v2(rsdpptr->Revision))
    {
        rsdp_20_ptr = (SDT::RSDP20 *)ptr;
        rsdp_ptr = rsdpptr;
    }
    else
    {
        rsdp_20_ptr = NULL;
        rsdp_ptr = rsdpptr;
    }
................................................................................
    if (acpi_version > 1)
        return (xsdt_ptr->h.Length - sizeof(SDT::generic_sdt) - 1) / 8;
    return (rsdt_ptr->h.Length - sizeof(SDT::generic_sdt) - 1) / 4;
}

void sdt_wrapper::set_rsdt(uint32_t physical_position)
{
    rsdt_ptr = (SDT::RSDT *)physical_position;
}

void sdt_wrapper::set_xsdt(uint32_t ptr)
{
    if (acpi_version > 1)
        xsdt_ptr = (SDT::XSDT *)ptr;
}

sdt_wrapper::sdt_wrapper()
{
    rsdp_ptr = UTILS::find_rsdp();
    if (rsdp_ptr == nullptr)
        Exception::kernel_panic("ACPI: no rsdp found, initialization of ACPI not "
................................................................................
    set_xsdt(rsdp_20_ptr->XsdtAddress);
    find_structures();
}

SDT::generic_sdt *sdt_wrapper::get_table(size_t index)
{
    if (acpi_version != 0)
        return (SDT::generic_sdt *)(xsdt_ptr->PointerToOtherSDT[index]);
    return (SDT::generic_sdt *)(rsdt_ptr->PointerToOtherSDT[index]);
}

void sdt_wrapper::set_fadt()
{
    fadt = fadt_wrapper((SDT::FADT *)get_table(0));
}

void sdt_wrapper::set_dsdt() 
{
    dsdt = dsdt_wrapper ((SDT::DSDT*) fadt.stored->Dsdt);
}

................................................................................
    set_fadt();
    set_dsdt();
    for (size_t i = 0; ft.all_found(); ++i)
    {
        SDT::generic_sdt *a = get_table(i);
        if (memcmp(a->Signature, "APIC", 4) == 0)
        {
            madt = madt_wrapper((SDT::MADT *)a);
            ft.APIC = true;
        }
    }
}

dsdt_wrapper::dsdt_wrapper(SDT::DSDT *other) { stored = other; }
dsdt_wrapper::dsdt_wrapper() { stored = nullptr; }

ksdk::string_view dsdt_wrapper::getCode()
{
    size_t length = stored->h.Length - sizeof(SDT::generic_sdt);
    char *start = (char *)stored->DefinitionBlock;
    return ksdk::string_view(start, length);
}

fadt_wrapper::fadt_wrapper(SDT::FADT *ptr) : stored(ptr)
{
    *&(stored->Reserved) = 0;
}

fadt_wrapper::fadt_wrapper() : stored(nullptr)
{
}

SDT::DSDT *fadt_wrapper::get_dsdt() { return (SDT::DSDT *)stored->Dsdt; }

void fadt_wrapper::enable_acpi()
{
    outb(stored->SMI_CommandPort, stored->AcpiEnable);
    while (inw(stored->PM1aControlBlock) & 1 == 0);
}

void fadt_wrapper::disable_acpi()
{
    outb(stored->SMI_CommandPort, stored->AcpiDisable);
}

} // namespace ACPI






|







 







|



|







 







|





|







 







|
|




|







 







|











|












|













9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
madt_wrapper::madt_wrapper() {}
bool madt_wrapper::is_out_of_bounds(size_t _offset)
{
    return _offset > (madt_ptr->h.Length - sizeof(SDT::generic_sdt));
}

SDT::GENERIC_MADT_ENTRY *madt_wrapper::get_current_entry(){
    return reinterpret_cast<SDT::GENERIC_MADT_ENTRY *>(&madt_ptr->Entries[offset]);
}

SDT::GENERIC_MADT_ENTRY *madt_wrapper::get_next_entry()
{
    if (is_out_of_bounds(offset))
        offset = 0;
    offset += get_current_entry()->RecordLength;
................................................................................
    return nullptr;
}

void madt_wrapper::reset_entry_pointer() { offset = 0; }

inline void sdt_wrapper::set_rsdp(void *ptr)
{
    SDT::RSDP *rsdpptr = reinterpret_cast<SDT::RSDP *>ptr;
    acpi_version = rsdpptr->Revision;
    if (UTILS::is_rsdp_v2(rsdpptr->Revision))
    {
        rsdp_20_ptr = reinterpret_cast<SDT::RSDP20 *>ptr;
        rsdp_ptr = rsdpptr;
    }
    else
    {
        rsdp_20_ptr = NULL;
        rsdp_ptr = rsdpptr;
    }
................................................................................
    if (acpi_version > 1)
        return (xsdt_ptr->h.Length - sizeof(SDT::generic_sdt) - 1) / 8;
    return (rsdt_ptr->h.Length - sizeof(SDT::generic_sdt) - 1) / 4;
}

void sdt_wrapper::set_rsdt(uint32_t physical_position)
{
    rsdt_ptr = reinterpret_cast<SDT::RSDT *>physical_position;
}

void sdt_wrapper::set_xsdt(uint32_t ptr)
{
    if (acpi_version > 1)
        xsdt_ptr = reinterpret_cast<SDT::XSDT *>ptr;
}

sdt_wrapper::sdt_wrapper()
{
    rsdp_ptr = UTILS::find_rsdp();
    if (rsdp_ptr == nullptr)
        Exception::kernel_panic("ACPI: no rsdp found, initialization of ACPI not "
................................................................................
    set_xsdt(rsdp_20_ptr->XsdtAddress);
    find_structures();
}

SDT::generic_sdt *sdt_wrapper::get_table(size_t index)
{
    if (acpi_version != 0)
        return reinterpret_cast<SDT::generic_sdt *>(xsdt_ptr->PointerToOtherSDT[index]);
    return reinterpret_cast<SDT::generic_sdt *>(rsdt_ptr->PointerToOtherSDT[index]);
}

void sdt_wrapper::set_fadt()
{
    fadt = fadt_wrapper(reinterpret_cast<SDT::FADT *>get_table(0));
}

void sdt_wrapper::set_dsdt() 
{
    dsdt = dsdt_wrapper ((SDT::DSDT*) fadt.stored->Dsdt);
}

................................................................................
    set_fadt();
    set_dsdt();
    for (size_t i = 0; ft.all_found(); ++i)
    {
        SDT::generic_sdt *a = get_table(i);
        if (memcmp(a->Signature, "APIC", 4) == 0)
        {
            madt = madt_wrapper(reinterpret_cast<SDT::MADT *>a);
            ft.APIC = true;
        }
    }
}

dsdt_wrapper::dsdt_wrapper(SDT::DSDT *other) { stored = other; }
dsdt_wrapper::dsdt_wrapper() { stored = nullptr; }

ksdk::string_view dsdt_wrapper::getCode()
{
    size_t length = stored->h.Length - sizeof(SDT::generic_sdt);
    char *start = reinterpret_cast<char *>stored->DefinitionBlock;
    return ksdk::string_view(start, length);
}

fadt_wrapper::fadt_wrapper(SDT::FADT *ptr) : stored(ptr)
{
    *&(stored->Reserved) = 0;
}

fadt_wrapper::fadt_wrapper() : stored(nullptr)
{
}

SDT::DSDT *fadt_wrapper::get_dsdt() { return reinterpret_cast<SDT::DSDT *>stored->Dsdt; }

void fadt_wrapper::enable_acpi()
{
    outb(stored->SMI_CommandPort, stored->AcpiEnable);
    while (inw(stored->PM1aControlBlock) & 1 == 0);
}

void fadt_wrapper::disable_acpi()
{
    outb(stored->SMI_CommandPort, stored->AcpiDisable);
}

} // namespace ACPI

Changes to src/buffers/vga_buffer.cpp.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	text_cursor = 0;
	text_color = make_color_mode(color::WHITE);
}

void initialize_buffers()
{

	buffer = ksdk::buffer<char>((char *)0x000A0000, (char *)0x000BFFFF);
	text_buffer = ksdk::buffer<character>((character *)0x000B8000,
										  TEXT_WIDTH * TEXT_HEIGHT);
}

void initialize()
{
	initialize_variables();
	initialize_buffers();






|
|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	text_cursor = 0;
	text_color = make_color_mode(color::WHITE);
}

void initialize_buffers()
{

	buffer = ksdk::buffer<char>(reinterpret_cast<char *>0x000A0000, reinterpret_cast<char *>0x000BFFFF);
	text_buffer = ksdk::buffer<character>(reinterpret_cast<character *>0x000B8000,
										  TEXT_WIDTH * TEXT_HEIGHT);
}

void initialize()
{
	initialize_variables();
	initialize_buffers();