The short version is: Add roofs to the keep, towers, and along the walls. But first let's understand the difference between castles and underground bunkers.
Castle vs Bunker
Castles use height as their defence, while bunkers use depth.
Height allows you to see further, to shoot further, and to get more angles of attack on incoming sieges. A tall wall also prevents siegers from just walking into your castle. In particular, it deals with the concern of cavalry, as it's difficult to get cavalry into a castle unless you control the gate house.
While a few bunkers are tall like a castle's keep, many sacrifice these advantages of height for greater defense against artillery. By burying yourself in dirt, you can use hundreds of tons of earth as a shield. They deny entry not with large stone walls, but with barbed wire which you can see and shoot through, and with powerful artillery and machine guns. They are heavily roofed, as they expect to be hit by indirect fire and air attack.
In the world wars, there were many fantastic bunker castles which were very expensive. These were pretty great, but the Germans in both wars demonstrated the ability to construct and transport massive artillery pieces which could tear these apart. So the cheaper and more effective bunker design was adopted.
How to defend against medieval flying creatures?
Short version is: Ranged weapons and roofs.
Man towers with light artillery weapons, probably ballistas, and light cannon if you have those. And plenty of ranged troops who can shoot any enemy that gets close. Keep look outs who watch the sky from several angles, to try and prevent the enemy using clouds and the sun as cover. And make sure there are roofs that protect your troops and deny intelligence to the enemy.
Magic, I'm less certain of. You could always try to rig a giant fly-zapper, if that works on hawkmen. Maybe cover your castle in magical wards that make curses and spells less effective?
You'll want roofs that your men can climb onto via ladders, so they can fight any flying enemies who land on the roofs. You also want to have it so that there are always some archers who have a clear shot at a given roof, so your towers and walls can cover each other against this.
And as always, firefighting will be important.
And for high-flying enemies... you'll want heavy mortar artillery if gunpowder is available, that'll preferably send exploding shrapnel ammo high into the sky (medieval flak). If you don't have that, you'll have to build something like a giant ballista that shoots bladed nets or something like that. Otherwise, all you can do is use magic or hire a flying creature to deal with these high fliers, your only other option being to try and ignore them and perform damage-control.
If flying creatures are a big problem in your area, more than cavalry and infantry, then you should just make a bunker.